Python Panda sqlalchemy
- By Preneesh AV --
- 15-Mar-2020 --
- 194 Comments
Few useful syntax:
orderBook.to_sql("orderbook", con = ad.engine, if_exists = 'append', chunksize = 1000, dtype={'None':VARCHAR(5)})
orderBook.to_sql("orderbook", con = ad.engine, if_exists = 'append', chunksize = 1000, dtype={col_name: NVARCHAR for col_name in df})
frame.to_sql('indexes',engine,if_exists='replace', index_label='index',dtype={frame.index.name:VARCHAR(5)})
frame.to_sql('rnd_vals', engine, dtype={'None':VARCHAR(5)})
my_df.reset_index()my_df.to_sql(name='my_table', con=engine, index=False, if_exists='replace')
column_errors.to_sql('load_errors',push_conn, if_exists ='append', index =False, dtype={'datefld': sqlalchemy.DateTime(),'intfld': sqlalchemy.types.INTEGER(),'strfld': sqlalchemy.types.NVARCHAR(length=255)'floatfld': sqlalchemy.types.Float(precision=3, asdecimal=True)'booleanfld': sqlalchemy.types.Boolean})