@@ -952,9 +952,6 @@ def test_date_parsing(self):
952
952
"IntDateCol loaded with incorrect type" )
953
953
954
954
def test_datetime (self ):
955
- if self .driver == 'pymysql' :
956
- raise nose .SkipTest ('writing datetime not working with pymysql' )
957
-
958
955
df = DataFrame ({'A' : date_range ('2013-01-01 09:00:00' , periods = 3 ),
959
956
'B' : np .arange (3.0 )})
960
957
df .to_sql ('test_datetime' , self .conn )
@@ -975,17 +972,6 @@ def test_datetime(self):
975
972
tm .assert_frame_equal (result , df )
976
973
977
974
def test_datetime_NaT (self ):
978
- # status:
979
- # - postgresql: gives error on inserting "0001-255-255T00:00:00"
980
- # - sqlite3: works, but reading it with query returns '-001--1--1 -1:-1:-1.-00001'
981
-
982
- if self .driver == 'pymysql' :
983
- raise nose .SkipTest ('writing datetime not working with pymysql' )
984
- if self .driver == 'psycopg2' :
985
- raise nose .SkipTest ('writing datetime NaT not working with psycopg2' )
986
- if self .flavor == 'sqlite' :
987
- raise nose .SkipTest ('reading datetime NaT not working with sqlite' )
988
-
989
975
df = DataFrame ({'A' : date_range ('2013-01-01 09:00:00' , periods = 3 ),
990
976
'B' : np .arange (3.0 )})
991
977
df .loc [1 , 'A' ] = np .nan
@@ -1032,9 +1018,6 @@ def test_mixed_dtype_insert(self):
1032
1018
tm .assert_frame_equal (df , df2 , check_dtype = False , check_exact = True )
1033
1019
1034
1020
def test_nan_numeric (self ):
1035
- if self .driver == 'pymysql' :
1036
- raise nose .SkipTest ('writing NaNs not working with pymysql' )
1037
-
1038
1021
# NaNs in numeric float column
1039
1022
df = DataFrame ({'A' :[0 , 1 , 2 ], 'B' :[0.2 , np .nan , 5.6 ]})
1040
1023
df .to_sql ('test_nan' , self .conn , index = False )
@@ -1048,37 +1031,27 @@ def test_nan_numeric(self):
1048
1031
tm .assert_frame_equal (result , df )
1049
1032
1050
1033
def test_nan_fullcolumn (self ):
1051
- if self .driver == 'pymysql' :
1052
- raise nose .SkipTest ('writing NaNs not working with pymysql' )
1053
-
1054
1034
# full NaN column (numeric float column)
1055
1035
df = DataFrame ({'A' :[0 , 1 , 2 ], 'B' :[np .nan , np .nan , np .nan ]})
1056
1036
df .to_sql ('test_nan' , self .conn , index = False )
1057
1037
1058
- if self .flavor == 'sqlite' :
1059
- df ['B' ] = df ['B' ].astype ('object' )
1060
- df ['B' ] = None
1061
-
1062
1038
# with read_table
1063
1039
result = sql .read_sql_table ('test_nan' , self .conn )
1064
1040
tm .assert_frame_equal (result , df )
1065
1041
1066
- # with read_sql
1042
+ # with read_sql -> not type info from table -> stays None
1043
+ df ['B' ] = df ['B' ].astype ('object' )
1044
+ df ['B' ] = None
1067
1045
result = sql .read_sql_query ('SELECT * FROM test_nan' , self .conn )
1068
1046
tm .assert_frame_equal (result , df )
1069
1047
1070
1048
def test_nan_string (self ):
1071
- if self .driver == 'pymysql' :
1072
- raise nose .SkipTest ('writing NaNs not working with pymysql' )
1073
-
1074
1049
# NaNs in string column
1075
1050
df = DataFrame ({'A' :[0 , 1 , 2 ], 'B' :['a' , 'b' , np .nan ]})
1076
1051
df .to_sql ('test_nan' , self .conn , index = False )
1077
1052
1078
- if self .flavor == 'sqlite' :
1079
- df .loc [2 , 'B' ] = None
1080
- elif self .flavor == 'postgresql' :
1081
- df = df .fillna ('NaN' )
1053
+ # NaNs are coming back as None
1054
+ df .loc [2 , 'B' ] = None
1082
1055
1083
1056
# with read_table
1084
1057
result = sql .read_sql_table ('test_nan' , self .conn )
0 commit comments