Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SNOW-1367466: pd_writer throwing : not all arguments converted during string formatting #1940

Open
mhasan09 opened this issue May 6, 2024 · 2 comments
Assignees
Labels
status-information_needed Additional information is required from the reporter status-triage_done Initial triage done, will be further handled by the driver team

Comments

@mhasan09
Copy link

mhasan09 commented May 6, 2024

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
@github-actions github-actions bot changed the title pd_writer throwing : not all arguments converted during string formatting SNOW-1367466: pd_writer throwing : not all arguments converted during string formatting May 6, 2024
@sfc-gh-sghosh sfc-gh-sghosh self-assigned this May 7, 2024
@sfc-gh-sghosh
Copy link

Hello @mhasan09 ,

Thank you for raising the issue, we are looking into it, will update.

Regards,
Sujan

@sfc-gh-sghosh sfc-gh-sghosh added status-triage Issue is under initial triage and removed bug needs triage labels May 7, 2024
@sfc-gh-sghosh
Copy link

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

@sfc-gh-sghosh sfc-gh-sghosh added status-triage_done Initial triage done, will be further handled by the driver team status-information_needed Additional information is required from the reporter and removed status-triage Issue is under initial triage labels May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status-information_needed Additional information is required from the reporter status-triage_done Initial triage done, will be further handled by the driver team
Projects
None yet
Development

No branches or pull requests

2 participants