@@ -435,6 +435,25 @@ def _to_sql_append(self):
435
435
assert num_rows == num_entries
436
436
self .drop_table ('test_frame1' )
437
437
438
+ def _to_sql_method_callable (self ):
439
+ check = [] # used to double check function below is really being used
440
+
441
+ def sample (pd_table , conn , keys , data_iter ):
442
+ check .append (1 )
443
+ data = [{k : v for k , v in zip (keys , row )} for row in data_iter ]
444
+ conn .execute (pd_table .table .insert (), data )
445
+ self .drop_table ('test_frame1' )
446
+
447
+ self .pandasSQL .to_sql (self .test_frame1 , 'test_frame1' , method = sample )
448
+ assert self .pandasSQL .has_table ('test_frame1' )
449
+
450
+ assert check == [1 ]
451
+ num_entries = len (self .test_frame1 )
452
+ num_rows = self ._count_rows ('test_frame1' )
453
+ assert num_rows == num_entries
454
+ # Nuke table
455
+ self .drop_table ('test_frame1' )
456
+
438
457
def _roundtrip (self ):
439
458
self .drop_table ('test_frame_roundtrip' )
440
459
self .pandasSQL .to_sql (self .test_frame1 , 'test_frame_roundtrip' )
@@ -1211,6 +1230,9 @@ def test_to_sql_append(self):
1211
1230
def test_to_sql_method_multi (self ):
1212
1231
self ._to_sql (method = 'multi' )
1213
1232
1233
+ def test_to_sql_method_callable (self ):
1234
+ self ._to_sql_method_callable ()
1235
+
1214
1236
def test_create_table (self ):
1215
1237
temp_conn = self .connect ()
1216
1238
temp_frame = DataFrame (
@@ -1686,7 +1708,6 @@ class _TestSQLiteAlchemy(object):
1686
1708
1687
1709
"""
1688
1710
flavor = 'sqlite'
1689
- supports_multivalues_insert = True
1690
1711
1691
1712
@classmethod
1692
1713
def connect (cls ):
@@ -1735,7 +1756,6 @@ class _TestMySQLAlchemy(object):
1735
1756
1736
1757
"""
1737
1758
flavor = 'mysql'
1738
- supports_multivalues_insert = True
1739
1759
1740
1760
@classmethod
1741
1761
def connect (cls ):
@@ -1805,7 +1825,6 @@ class _TestPostgreSQLAlchemy(object):
1805
1825
1806
1826
"""
1807
1827
flavor = 'postgresql'
1808
- supports_multivalues_insert = True
1809
1828
1810
1829
@classmethod
1811
1830
def connect (cls ):
0 commit comments