snowflake-connector-python
snowflake-connector-python copied to clipboard
SNOW-1367466: pd_writer throwing : not all arguments converted during string formatting
Python version
3.10.7
Operating system and processor architecture
windows 11
Installed packages
SQLAlchemy==1.4.52
snowflake-sqlalchemy==1.5.3
snowflake-connector-python==3.10.0
pandas==2.2.2
What did you do?
engine = create_engine(url)
loan_file = "loan_9.csv"
df = pd.read_csv(loan_file, sep=",", header=0, index_col=False)
with engine.connect() as con:
df.to_sql(name='LOAN_PAYMENT', con=con.connection, index=False, method=pd_writer, if_exists='append')
What did you expect to see?
Expected the example to work, but got
Execution failed on sql '
SELECT
name
FROM
sqlite_master
WHERE
type IN ('table', 'view')
AND name=?;
': not all arguments converted during string formatting
Hello @mhasan09 ,
Thank you for raising the issue, we are looking into it, will update.
Regards, Sujan
Hello @mhasan09 ,
We tried to reproduce it with below code snippet, but its not throwing above error, its working fine.
using below versions
import sqlalchemy print(sqlalchemy.version) import snowflake.sqlalchemy print(snowflake.sqlalchemy.version)
1.4.52 1.5.3
`from sqlalchemy import create_engine import pandas as pd
Load your CSV data into a DataFrame
loan_file = "File1.csv" df = pd.read_csv(loan_file, sep=",", header=0, index_col=False)
engine = create_engine(URL( account = 'xxxx', user = 'xxx', password = 'xxx', database = 'SAMPLEDATABASE', schema = 'TEST', warehouse = 'SUJAN_WH', role='xxxx', ))
try: connection = engine.connect() results = connection.execute('select current_version()').fetchone() print(results[0])
Write the DataFrame to Snowflake using SQLAlchemy
with engine.connect() as con:
df.to_sql(name='mycsvtable2', con=con, index=False, if_exists='append')
finally: connection.close() engine.dispose()`
Its writing to table perfectly
Regards, Sujan
Hello @mhasan09 ,
There was no response and the issue is not getting reproduced, closing it. Feel free to reopen when reproduced and provide us the required artifacts.
Regards, Sujan