<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Lucas Silva</title>
    <description>The latest articles on DEV Community by Lucas Silva (@lucasdsbr).</description>
    <link>https://dev.to/lucasdsbr</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1108200%2F67284f13-1442-4ea9-8dba-fa83768d4ad9.jpeg</url>
      <title>DEV Community: Lucas Silva</title>
      <link>https://dev.to/lucasdsbr</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/lucasdsbr"/>
    <language>en</language>
    <item>
      <title>Connect Python with MySQL database ( mysql-connector )</title>
      <dc:creator>Lucas Silva</dc:creator>
      <pubDate>Sun, 25 Jun 2023 23:10:21 +0000</pubDate>
      <link>https://dev.to/lucasdsbr/connect-python-with-mysql-database-3ep0</link>
      <guid>https://dev.to/lucasdsbr/connect-python-with-mysql-database-3ep0</guid>
      <description>&lt;p&gt;Training my english !!!&lt;br&gt;
Hello, my name is Lucas. I be writing this artigle for sharing an code for connect python with database MySQL.&lt;/p&gt;

&lt;p&gt;For connecting python in database mysql, we require install an library ( mysql-connector ). For install this library, you can write in your concolse the command(using PIP):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install mysql-connector-python
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;With library instaling, we can initialize the create code for connection. In your VSCode, create an file with name "app.py";&lt;/li&gt;
&lt;li&gt;In your file "app.py" import the library ( mysql-connector ) writing the this line:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import mysql.connector
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;In your file "app.py" write the code with data the connectio MySQL
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mydb = mysql.connector.connect(
    host='',
    user='',
    password='',
    database=''
)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;host&lt;/code&gt;: the host of connection in database MySQL;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;user&lt;/code&gt;: username of connection in database;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;password&lt;/code&gt;: password of connection in database;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;database&lt;/code&gt;: name of your database&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For finality the code, we have to write the line of conection:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;con = mydb.cursor()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Your code should look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import mysql.connector

mydb = mysql.connector.connect(
    host='',
    user='',
    password='',
    database=''
)

con = mydb.cursor()

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>python</category>
      <category>database</category>
      <category>mysql</category>
    </item>
  </channel>
</rss>
