@@ -1779,6 +1779,108 @@ def test_read_csv_list_iterator(bucket, sample, row_num):
17791779 assert total_count == row_num * n
17801780
17811781
1782+ def test_aurora_mysql_load_append (bucket , mysql_parameters ):
1783+ n : int = 10_000
1784+ df = pd .DataFrame ({"id" : list ((range (n ))), "value" : list (["foo" if i % 2 == 0 else "boo" for i in range (n )])})
1785+ conn = Aurora .generate_connection (database = "mysql" ,
1786+ host = mysql_parameters ["MysqlAddress" ],
1787+ port = 3306 ,
1788+ user = "test" ,
1789+ password = mysql_parameters ["Password" ],
1790+ engine = "mysql" )
1791+ path = f"s3://{ bucket } /test_aurora_mysql_load_append"
1792+
1793+ # LOAD
1794+ wr .pandas .to_aurora (dataframe = df ,
1795+ connection = conn ,
1796+ schema = "test" ,
1797+ table = "test_aurora_mysql_load_append" ,
1798+ mode = "overwrite" ,
1799+ temp_s3_path = path )
1800+ with conn .cursor () as cursor :
1801+ cursor .execute ("SELECT count(*) FROM test.test_aurora_mysql_load_append" )
1802+ count = cursor .fetchall ()[0 ][0 ]
1803+ assert count == len (df .index )
1804+
1805+ # APPEND
1806+ wr .pandas .to_aurora (dataframe = df ,
1807+ connection = conn ,
1808+ schema = "test" ,
1809+ table = "test_aurora_mysql_load_append" ,
1810+ mode = "append" ,
1811+ temp_s3_path = path )
1812+ with conn .cursor () as cursor :
1813+ cursor .execute ("SELECT count(*) FROM test.test_aurora_mysql_load_append" )
1814+ count = cursor .fetchall ()[0 ][0 ]
1815+ assert count == len (df .index ) * 2
1816+
1817+ # RESET
1818+ wr .pandas .to_aurora (dataframe = df ,
1819+ connection = conn ,
1820+ schema = "test" ,
1821+ table = "test_aurora_mysql_load_append" ,
1822+ mode = "overwrite" ,
1823+ temp_s3_path = path )
1824+ with conn .cursor () as cursor :
1825+ cursor .execute ("SELECT count(*) FROM test.test_aurora_mysql_load_append" )
1826+ count = cursor .fetchall ()[0 ][0 ]
1827+ assert count == len (df .index )
1828+
1829+ conn .close ()
1830+
1831+
1832+ def test_aurora_postgres_load_append (bucket , postgres_parameters ):
1833+ df = pd .DataFrame ({"id" : [1 , 2 , 3 ], "value" : ["foo" , "boo" , "bar" ]})
1834+ conn = Aurora .generate_connection (database = "postgres" ,
1835+ host = postgres_parameters ["PostgresAddress" ],
1836+ port = 3306 ,
1837+ user = "test" ,
1838+ password = postgres_parameters ["Password" ],
1839+ engine = "postgres" )
1840+ path = f"s3://{ bucket } /test_aurora_postgres_load_append"
1841+
1842+ # LOAD
1843+ wr .pandas .to_aurora (dataframe = df ,
1844+ connection = conn ,
1845+ schema = "public" ,
1846+ table = "test_aurora_postgres_load_append" ,
1847+ mode = "overwrite" ,
1848+ temp_s3_path = path ,
1849+ engine = "postgres" )
1850+ with conn .cursor () as cursor :
1851+ cursor .execute ("SELECT count(*) FROM public.test_aurora_postgres_load_append" )
1852+ count = cursor .fetchall ()[0 ][0 ]
1853+ assert count == len (df .index )
1854+
1855+ # APPEND
1856+ wr .pandas .to_aurora (dataframe = df ,
1857+ connection = conn ,
1858+ schema = "public" ,
1859+ table = "test_aurora_postgres_load_append" ,
1860+ mode = "append" ,
1861+ temp_s3_path = path ,
1862+ engine = "postgres" )
1863+ with conn .cursor () as cursor :
1864+ cursor .execute ("SELECT count(*) FROM public.test_aurora_postgres_load_append" )
1865+ count = cursor .fetchall ()[0 ][0 ]
1866+ assert count == len (df .index ) * 2
1867+
1868+ # RESET
1869+ wr .pandas .to_aurora (dataframe = df ,
1870+ connection = conn ,
1871+ schema = "public" ,
1872+ table = "test_aurora_postgres_load_append" ,
1873+ mode = "overwrite" ,
1874+ temp_s3_path = path ,
1875+ engine = "postgres" )
1876+ with conn .cursor () as cursor :
1877+ cursor .execute ("SELECT count(*) FROM public.test_aurora_postgres_load_append" )
1878+ count = cursor .fetchall ()[0 ][0 ]
1879+ assert count == len (df .index )
1880+
1881+ conn .close ()
1882+
1883+
17821884def test_to_csv_metadata (
17831885 session ,
17841886 bucket ,
0 commit comments