Skip to content

Instantly share code, notes, and snippets.

@StephenFordham
Created May 13, 2019 18:04
Show Gist options
  • Save StephenFordham/b1af5b54e16e7f2b38e9a63e4592adc9 to your computer and use it in GitHub Desktop.
Save StephenFordham/b1af5b54e16e7f2b38e9a63e4592adc9 to your computer and use it in GitHub Desktop.
DataFrame_to_sql
import mysql.connector
mydb = mysql.connector.connect(
host='localhost',
user='root',
password='****',
database='football_db'
)
print(mydb)
print(players_data.columns)
cursor = mydb.cursor()
query = '''CREATE TABLE player_data
( Name text(255), Age int(10), Nationality text(255), Overall int(10), Potential text(255), Club text(255),
Value_Millions int(10)…
);'''
cursor.execute(query)
players_data.to_sql(name='player_data', con=engine, index=False, if_exists='append')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment