|
29 | 29 | from datetime import datetime
|
30 | 30 |
|
31 | 31 | from pandas import DataFrame, Series, Index, MultiIndex, isnull
|
| 32 | +from pandas import to_timedelta |
32 | 33 | import pandas.compat as compat
|
33 | 34 | from pandas.compat import StringIO, range, lrange
|
34 | 35 | from pandas.core.datetools import format as date_format
|
35 | 36 |
|
36 | 37 | import pandas.io.sql as sql
|
37 | 38 | import pandas.util.testing as tm
|
| 39 | +from pandas import _np_version_under1p7 |
38 | 40 |
|
39 | 41 |
|
40 | 42 | try:
|
@@ -475,6 +477,17 @@ def test_date_and_index(self):
|
475 | 477 | self.assertTrue(issubclass(df.IntDateCol.dtype.type, np.datetime64),
|
476 | 478 | "IntDateCol loaded with incorrect type")
|
477 | 479 |
|
| 480 | + def test_timedelta(self): |
| 481 | + # see #6921 |
| 482 | + if _np_version_under1p7: |
| 483 | + raise nose.SkipTest("test only valid in numpy >= 1.7") |
| 484 | + |
| 485 | + df = to_timedelta(Series(['00:00:01', '00:00:03'], name='foo')).to_frame() |
| 486 | + with tm.assert_produces_warning(UserWarning): |
| 487 | + df.to_sql('test_timedelta', self.conn) |
| 488 | + result = sql.read_sql_query('SELECT * FROM test_timedelta', self.conn) |
| 489 | + tm.assert_series_equal(result['foo'], df['foo'].astype('int64')) |
| 490 | + |
478 | 491 | def test_to_sql_index_label(self):
|
479 | 492 | temp_frame = DataFrame({'col1': range(4)})
|
480 | 493 |
|
|
0 commit comments