Skip to content

Instantly share code, notes, and snippets.

@StephenFordham
Created May 8, 2019 18:09
Show Gist options
  • Save StephenFordham/a3a4e2ecea526bbbf99c33070952fa53 to your computer and use it in GitHub Desktop.
Save StephenFordham/a3a4e2ecea526bbbf99c33070952fa53 to your computer and use it in GitHub Desktop.
database_connection
import mysql.connector
mydb = mysql.connector.connect(
host='localhost',
user='root',
password='******',
#database='football_db'
)
print(mydb)
cursor = mydb.cursor()
cursor.execute("CREATE DATABASE football_db")
cursor.execute('SHOW DATABASES')
Output:
<mysql.connector.connection.MySQLConnection object at 0x030D98F0>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment