Created
May 13, 2019 18:04
-
-
Save StephenFordham/b1af5b54e16e7f2b38e9a63e4592adc9 to your computer and use it in GitHub Desktop.
DataFrame_to_sql
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
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