pydata/pandas — pull request #7082 by jorisvandenbossche (2014-05-08 21:40:56+00:00)
Title: SQL: datetime writing: add tests + issue with pymysql

There were apparantly not yet tests for writing datetime data. So added a test case for both query/table.

For MySQL using the pymysql driver, writing a datetime column is not working ... It gives following error:

```
In [65]: import pymysql
In [66]: engine_mysql = sqlalchemy.create_engine('mysql+pymysql://root@localhost/pandas_nosetest')
In [67]: df = pd.DataFrame({'A': pd.date_range('2013-01-01 09:00:00', periods=3),
...: 'B': np.arange(3.0)})
In [68]: df.to_sql('test_datetime', engine_mysql, if_exists='replace')
Traceback (most recent call last):
File "", line 1, in
df.to_sql('test_datetime', engine_mysql, if_exists='replace')
...
File "C:\Anaconda\envs\devel\lib\site-packages\pymysql\converters.py", line 24, in escape_item
encoder = encoders[type(val)]

KeyError:
```

The data are feeded to the database using `df.itertuples()` and then `np.asscalar()`, and apparantly this gives data of the `Timestamp` class. And for some reason the other drivers can handle this (because it is