Created
November 26, 2018 11:03
-
-
Save crazyrohila/70ede8cf52af02232e4ebd2cc6dcf9f1 to your computer and use it in GitHub Desktop.
Google-sheet-import
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
engine = create_engine('postgresql://username:password@host/dbname') | |
scope = ['https://spreadsheets.google.com/feeds'] | |
creds = ServiceAccountCredentials.from_json_keyfile_name('credentials.json', scope) | |
client = gspread.authorize(creds) | |
workbook = client.open_by_url('google-sheet-url') | |
sheet = workbook.worksheet("Tab/sheet to import") | |
data = sheet.get_all_records(head=1, default_blank=None) | |
data = pd.DataFrame(data) | |
data.to_sql(name='table-name', con= engine, if_exists='replace') |
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
pandas==0.20.3 | |
gspread | |
sqlalchemy==1.1.14 | |
oauth2client | |
psycopg2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment