Cannot import timezone aware datetimes from pandas into SQL
- Dominant language
- Python
- Stars
- 1k
- Forks
- 131
- PR merge metrics
- No merged PRs in 30d
Description
**Problem**: The following code generates a type error:
```
import pytz
import sqlalchemy as sa
import pandas as pd
from odo import odo
from datetime import datetime
engine = sa.create_engine('sqlite://', echo=True)
metadata = sa.MetaData(bind=engine)
test_table = sa.Table('test', metadata,
sa.Column('date', sa.DateTime()),
extend_existing=True)
metadata.create_all(checkfirst=True)
df = pd.DataFrame({'date': [datetime.now(tz=pytz.UTC)]})
odo(df, test_table)
```
```
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
in ()
15
16 df = pd.DataFrame({'date': [datetime.now(tz=pytz.UTC)]})
---> 17 odo(df, test_table)
...
/Users/matt/anaconda/envs/test/lib/python3.5/site-packages/numpy/core/numerictypes.py in issubdtype(arg1, arg2)
753 """
754 if issubclass_(arg2, generic):
--> 755 return issubclass(dtype(arg1).type, arg2)
756 mro = dtype(arg2).type.mro()
757 if len(mro) > 1:
TypeError: data type not understood
```
**Expectation**: Either load the datetime (preferable) or give a more descriptive error (e.g. "Timezone Aware Datetime Objects are not supported")
**Notes**:
Removing tz=pytz.UTC fixes it.
Might be related to https://github.com/blaze/odo/issues/401
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.