to_sql pyodbc count field incorrect or syntax error

后端 未结 3 1590
死守一世寂寞
死守一世寂寞 2020-12-05 16:02

I am downloading Json data from an api website and using sqlalchemy, pyodbc and pandas\' to_sql function to insert that data into a MSSQL server.

I can download up

3条回答
  •  旧巷少年郎
    2020-12-05 16:12

    Made a few modifications based on Gord Thompson's answer. This will auto-calculate the chunksize and keep it to the lowest nearest integer value which fits in the 2100 parameters limit :

    import math
    df_num_of_cols=len(df.columns)
    chunknum=math.floor(2100/df_num_of_cols)
    df.to_sql('MY_TABLE',con=engine,schema='myschema',chunksize=chunknum,if_exists='append',method='multi',index=False )
    

提交回复
热议问题