Created
April 22, 2014 13:15
-
-
Save danielballan/11178744 to your computer and use it in GitHub Desktop.
Traceback for pandas SQL timedelta issue
This file contains 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
In [27]: df.to_sql('bar', engine, index=False) | |
--------------------------------------------------------------------------- | |
StatementError Traceback (most recent call last) | |
<ipython-input-27-7476a9ea602a> in <module>() | |
----> 1 df.to_sql('bar', engine, index=False) | |
/Users/danielallan/Documents/Repos/pandas-danielballan/pandas/core/generic.py in to_sql(self, name, con, flavor, if_exists, index, index_label) | |
940 sql.to_sql( | |
941 self, name, con, flavor=flavor, if_exists=if_exists, index=index, | |
--> 942 index_label=index_label) | |
943 | |
944 def to_pickle(self, path): | |
/Users/danielallan/Documents/Repos/pandas-danielballan/pandas/io/sql.py in to_sql(frame, name, con, flavor, if_exists, index, index_label) | |
390 | |
391 pandas_sql.to_sql(frame, name, if_exists=if_exists, index=index, | |
--> 392 index_label=index_label) | |
393 | |
394 | |
/Users/danielallan/Documents/Repos/pandas-danielballan/pandas/io/sql.py in to_sql(self, frame, name, if_exists, index, index_label) | |
765 name, self, frame=frame, index=index, if_exists=if_exists, | |
766 index_label=index_label) | |
--> 767 table.insert() | |
768 | |
769 @property | |
/Users/danielallan/Documents/Repos/pandas-danielballan/pandas/io/sql.py in insert(self) | |
529 data_list.append(data) | |
530 | |
--> 531 self.pd_sql.execute(ins, data_list) | |
532 | |
533 def read(self, coerce_float=True, parse_dates=None, columns=None): | |
/Users/danielallan/Documents/Repos/pandas-danielballan/pandas/io/sql.py in execute(self, *args, **kwargs) | |
725 def execute(self, *args, **kwargs): | |
726 """Simple passthrough to SQLAlchemy engine""" | |
--> 727 return self.engine.execute(*args, **kwargs) | |
728 | |
729 def tquery(self, *args, **kwargs): | |
/Users/danielallan/anaconda/lib/python2.7/site-packages/sqlalchemy/engine/base.pyc in execute(self, statement, *multiparams, **params) | |
1612 | |
1613 connection = self.contextual_connect(close_with_result=True) | |
-> 1614 return connection.execute(statement, *multiparams, **params) | |
1615 | |
1616 def scalar(self, statement, *multiparams, **params): | |
/Users/danielallan/anaconda/lib/python2.7/site-packages/sqlalchemy/engine/base.pyc in execute(self, object, *multiparams, **params) | |
660 object, | |
661 multiparams, | |
--> 662 params) | |
663 else: | |
664 raise exc.InvalidRequestError( | |
/Users/danielallan/anaconda/lib/python2.7/site-packages/sqlalchemy/engine/base.pyc in _execute_clauseelement(self, elem, multiparams, params) | |
759 compiled_sql, | |
760 distilled_params, | |
--> 761 compiled_sql, distilled_params | |
762 ) | |
763 if self._has_events: | |
/Users/danielallan/anaconda/lib/python2.7/site-packages/sqlalchemy/engine/base.pyc in _execute_context(self, dialect, constructor, statement, parameters, *args) | |
826 self._handle_dbapi_exception(e, | |
827 str(statement), parameters, | |
--> 828 None, None) | |
829 | |
830 if context.compiled: | |
/Users/danielallan/anaconda/lib/python2.7/site-packages/sqlalchemy/engine/base.pyc in _handle_dbapi_exception(self, e, statement, parameters, cursor, context) | |
1022 self.dialect.dbapi.Error, | |
1023 connection_invalidated=self._is_disconnect), | |
-> 1024 exc_info | |
1025 ) | |
1026 | |
/Users/danielallan/anaconda/lib/python2.7/site-packages/sqlalchemy/util/compat.pyc in raise_from_cause(exception, exc_info) | |
194 # the code line where the issue occurred | |
195 exc_type, exc_value, exc_tb = exc_info | |
--> 196 reraise(type(exception), exception, tb=exc_tb) | |
197 | |
198 | |
/Users/danielallan/anaconda/lib/python2.7/site-packages/sqlalchemy/engine/base.pyc in _execute_context(self, dialect, constructor, statement, parameters, *args) | |
822 conn = self._revalidate_connection() | |
823 | |
--> 824 context = constructor(dialect, self, conn, *args) | |
825 except Exception, e: | |
826 self._handle_dbapi_exception(e, | |
/Users/danielallan/anaconda/lib/python2.7/site-packages/sqlalchemy/engine/default.pyc in _init_compiled(cls, dialect, connection, dbapi_connection, compiled, parameters) | |
457 for key in self.compiled.positiontup: | |
458 if key in processors: | |
--> 459 param.append(processors[key](compiled_params[key])) | |
460 else: | |
461 param.append(compiled_params[key]) | |
/Users/danielallan/anaconda/lib/python2.7/site-packages/sqlalchemy/types.pyc in process(value) | |
2287 def process(value): | |
2288 if value is not None: | |
-> 2289 value = epoch + value | |
2290 return impl_processor(value) | |
2291 else: | |
StatementError: unsupported operand type(s) for +: 'datetime.datetime' and 'long' (original cause: TypeError: unsupported operand type(s) for +: 'datetime.datetime' and 'long') 'INSERT INTO bar (foo) VALUES (?)' [{'foo': 1000000000L}, {'foo': 3000000000L}] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment