Skip to content

Instantly share code, notes, and snippets.

@enric1994
Created November 18, 2018 18:20
Show Gist options
  • Select an option

  • Save enric1994/cc9a1866db8e3aa2f494cabdfe979dc2 to your computer and use it in GitHub Desktop.

Select an option

Save enric1994/cc9a1866db8e3aa2f494cabdfe979dc2 to your computer and use it in GitHub Desktop.
MySQL Python3 connector
#!/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