diff options
author | Kyle K <kylek389@gmail.com> | 2020-09-26 02:02:56 -0500 |
---|---|---|
committer | Kyle K <kylek389@gmail.com> | 2020-09-26 02:02:56 -0500 |
commit | 87f79d843ec3df0727c0e8a68557930c507f3619 (patch) | |
tree | c36eb7f85145f126a031510b53faa14fe369adc8 | |
parent | 9b90b407ed54c8fecee7e84d69701cfe951368ac (diff) | |
download | PythonPractice-87f79d843ec3df0727c0e8a68557930c507f3619.tar.gz PythonPractice-87f79d843ec3df0727c0e8a68557930c507f3619.tar.bz2 PythonPractice-87f79d843ec3df0727c0e8a68557930c507f3619.zip |
mysql connect to db from python
-rw-r--r-- | sql1.py | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -0,0 +1,16 @@ +# pip install mysql-connector-python + +import mysql.connector + +mydb = mysql.connector.connect( + host="localhost", + user="root", + password="foobar", + database="employees" +) + +mycursor = mydb.cursor() +mycursor.execute("SHOW TABLES") +myresult = mycursor.fetchall() +for x in myresult: + print(x)
\ No newline at end of file |