@@ -792,6 +792,15 @@ def _get_index_columns(self, tbl_name):
792
792
ixs = [i ['column_names' ] for i in ixs ]
793
793
return ixs
794
794
795
+ def test_sqlalchemy_type_mapping (self ):
796
+
797
+ # Test Timestamp objects (no datetime64 because of timezone) (GH9085)
798
+ df = DataFrame ({'time' : to_datetime (['201412120154' , '201412110254' ],
799
+ utc = True )})
800
+ db = sql .SQLDatabase (self .conn )
801
+ table = sql .SQLTable ("test_type" , db , frame = df )
802
+ self .assertTrue (isinstance (table .table .c ['time' ].type , sqltypes .DateTime ))
803
+
795
804
796
805
class TestSQLiteFallbackApi (_TestSQLApi ):
797
806
"""
@@ -853,6 +862,24 @@ def test_uquery(self):
853
862
rows = sql .uquery ("SELECT * FROM iris LIMIT 1" , con = self .conn )
854
863
self .assertEqual (rows , - 1 )
855
864
865
+ def _get_sqlite_column_type (self , schema , column ):
866
+
867
+ for col in schema .split ('\n ' ):
868
+ if col .split ()[0 ].strip ('[]' ) == column :
869
+ return col .split ()[1 ]
870
+ raise ValueError ('Column %s not found' % (column ))
871
+
872
+ def test_sqlite_type_mapping (self ):
873
+
874
+ # Test Timestamp objects (no datetime64 because of timezone) (GH9085)
875
+ df = DataFrame ({'time' : to_datetime (['201412120154' , '201412110254' ],
876
+ utc = True )})
877
+ db = sql .SQLiteDatabase (self .conn , self .flavor )
878
+ table = sql .SQLiteTable ("test_type" , db , frame = df )
879
+ schema = table .sql_schema ()
880
+ self .assertEqual (self ._get_sqlite_column_type (schema , 'time' ),
881
+ "TIMESTAMP" )
882
+
856
883
857
884
#------------------------------------------------------------------------------
858
885
#--- Database flavor specific tests
@@ -1571,15 +1598,15 @@ def test_dtype(self):
1571
1598
1572
1599
# sqlite stores Boolean values as INTEGER
1573
1600
self .assertEqual (self ._get_sqlite_column_type ('dtype_test' , 'B' ), 'INTEGER' )
1574
-
1601
+
1575
1602
self .assertEqual (self ._get_sqlite_column_type ('dtype_test2' , 'B' ), 'STRING' )
1576
1603
self .assertRaises (ValueError , df .to_sql ,
1577
1604
'error' , self .conn , dtype = {'B' : bool })
1578
1605
1579
1606
def test_notnull_dtype (self ):
1580
1607
if self .flavor == 'mysql' :
1581
1608
raise nose .SkipTest ('Not applicable to MySQL legacy' )
1582
-
1609
+
1583
1610
cols = {'Bool' : Series ([True ,None ]),
1584
1611
'Date' : Series ([datetime (2012 , 5 , 1 ), None ]),
1585
1612
'Int' : Series ([1 , None ], dtype = 'object' ),
0 commit comments