Created
November 18, 2018 18:20
-
-
Save enric1994/cc9a1866db8e3aa2f494cabdfe979dc2 to your computer and use it in GitHub Desktop.
MySQL Python3 connector
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/python3 | |
| #pip install mysql-connector-python | |
| import mysql.connector | |
| cnx = mysql.connector.connect(user='user',password='password',host='hostname', database='dbname') | |
| cursor = cnx.cursor() | |
| cursor.execute('SELECT * FROM users') | |
| response= cursor.fetchall() | |
| cnx.commit() | |
| cursor.close() | |
| print(response) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment