python - executemany is not working -


i want copy dataframe sql table, to_sql not working in machine due sqlalchemy issue. so, tried executemany option. but, getting error while execution.

import pyodbc import pandas  connstring = 'driver={microsoft odbc oracle};server=servername;uid=user;pwd=password;' cnxn = pyodbc.connect(connstring) cur=cnxn.cursor() df = pandas.read_sql_query(sql="select * users",con=cnxn)  tbl_name = "users_new" wildcards = ','.join(['?'] * len(df.columns)) data = [tuple(x) x in df.values] print(data) [(u'p', u'poonam'), (u'm', u'mani'), (u'p', u'poonam'), (u'm', u'mani'), (u'p', u'poonam'), (u'm', u'mani')] dbcur = cnxn.cursor() #dbcur.execute("create table %s(id char(1), name char(9))" %(tbl_name))  dbcur.executemany("insert %s values(%s)" %(tbl_name,wildcards), [('1','11'),('2','22')])   #working cnxn.commit()  dbcur.executemany("insert %s values(%s)" %(tbl_name,wildcards), data)   #not working cnxn.commit() dbcur.close() cnxn.close() 

traceback (most recent call last):

file "c:/users/raska_000/desktop/loaddata", line 20, in <module>     dbcur.executemany("insert %s values(%s)" %(tbl_name,wildcards), data)   #not working error: ('hy004', '[hy004] [microsoft][odbc driver manager] sql data type out of range (0) (sqlbindparameter)') 

any appreciated.


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -