@@ -329,8 +329,24 @@ def test_pandas_writeback(engine_testaccount, run_v20_sqlalchemy):
329
329
)
330
330
331
331
332
- @pytest .mark .parametrize ("quote_identifiers" , [False , True ])
333
- def test_pandas_make_pd_writer (engine_testaccount , quote_identifiers ):
332
+ @pytest .mark .parametrize ("chunk_size" , [5 , 1 ])
333
+ @pytest .mark .parametrize (
334
+ "compression" ,
335
+ [
336
+ "gzip" ,
337
+ ],
338
+ )
339
+ @pytest .mark .parametrize ("parallel" , [1 , 4 ])
340
+ @pytest .mark .parametrize ("quote_identifiers" , [True , False ])
341
+ @pytest .mark .parametrize ("auto_create_table" , [True , False ])
342
+ def test_pandas_make_pd_writer (
343
+ engine_testaccount ,
344
+ chunk_size : int ,
345
+ compression : str ,
346
+ parallel : int ,
347
+ quote_identifiers : bool ,
348
+ auto_create_table : bool ,
349
+ ):
334
350
table_name = f"test_table_{ uuid .uuid4 ().hex } " .upper ()
335
351
test_df = pd .DataFrame ({"a" : range (10 ), "b" : range (10 , 20 )})
336
352
@@ -339,7 +355,13 @@ def write_to_db():
339
355
table_name ,
340
356
engine_testaccount ,
341
357
index = False ,
342
- method = make_pd_writer (quote_identifiers = quote_identifiers ),
358
+ method = make_pd_writer (
359
+ chunk_size = chunk_size ,
360
+ compression = compression ,
361
+ parallel = parallel ,
362
+ quote_identifiers = quote_identifiers ,
363
+ auto_create_table = auto_create_table ,
364
+ ),
343
365
)
344
366
345
367
with engine_testaccount .connect () as conn :
@@ -362,3 +384,30 @@ def write_to_db():
362
384
assert len (results ) == 10
363
385
finally :
364
386
conn .exec_driver_sql (f"DROP TABLE IF EXISTS { table_name } " )
387
+
388
+
389
+ def test_pandas_invalid_make_pd_writer (engine_testaccount ):
390
+ table_name = f"test_table_{ uuid .uuid4 ().hex } " .upper ()
391
+ test_df = pd .DataFrame ({"a" : range (10 ), "b" : range (10 , 20 )})
392
+
393
+ with pytest .raises (
394
+ ProgrammingError ,
395
+ match = "Arguments 'table', 'conn', 'keys', and 'data_iter' are not supported parameters for make_pd_writer." ,
396
+ ):
397
+ test_df .to_sql (
398
+ table_name ,
399
+ engine_testaccount ,
400
+ index = False ,
401
+ method = make_pd_writer (conn = engine_testaccount ),
402
+ )
403
+
404
+ with pytest .raises (
405
+ ProgrammingError ,
406
+ match = "Arguments 'conn', 'df', 'table_name', and 'schema' are not supported parameters for pd_writer." ,
407
+ ):
408
+ test_df .to_sql (
409
+ table_name ,
410
+ engine_testaccount ,
411
+ index = False ,
412
+ method = make_pd_writer (df = test_df ),
413
+ )
0 commit comments