I have a fairly big pandas dataframe - 50
or so headers and a few hundred thousand rows of data - and I'm looking to transfer this data to a database using the ceODBC
module. Previously I was using pyodbc
and using a simple execute statement in a for loop but this was taking ridiculously long (1000 records per 10 minutes)...
I'm now trying a new module and am trying to introduce executemany()
although I'm not quite sure what's meant by sequence of parameters in:
cursor.executemany("""insert into table.name(a, b, c, d, e, f)
values(?, ?, ?, ?, ?), sequence_of_parameters)
should it look like a constant list working through each header like
['asdas', '1', '2014-12-01', 'true', 'asdasd', 'asdas', '2',
'2014-12-02', 'true', 'asfasd', 'asdfs', '3', '2014-12-03', 'false', 'asdasd']
- where this is an example of three rows
or what is the format that's needed?
as another related question, how then can I go about converting a regular pandas dataframe to this format?
Thanks!
pymssql
? (but I don't have experience if this is faster aspyodbc
) But with that you can just useto_sql
pandas method (the driver has to be supported by sqlalchemy to be able to use this with pandas) – Reading