sinan yılmaz
sinan yılmaz

Reputation: 163

got multiple values for argument 'schema'

    self.engine=create_engine("postgresql://postgres:12345@localhost/postgres")
            self.con = self.engine.connect()
            self.conn.autocommit = True
            self.cursor = self.conn.cursor()

     
df.to_sql(symbol, schema='xxx', con=self.con, if_exists='append',
                      index=False)


    df.to_sql(symbol, con=self.con, if_exists='append',
                      index=False)

I am getting this error in both cases while adding the dataframe to the postgre sql database

meta = MetaData(self.connectable, schema=schema)

TypeError: init() got multiple values for argument 'schema'

Upvotes: 11

Views: 13829

Answers (4)

mare011
mare011

Reputation: 197

I had this issue on Databricks with pandas==1.5.3 and SQLAlchemy==2.0.34. Nothing above helped, and for some reason after I included typing_extensions==4.12.2 in requirements.txt everything started working fine.

Upvotes: 0

Stavros Koureas
Stavros Koureas

Reputation: 1472

As is described in other comments and answers, this is an indication of a mismatch between pandas and SQLAlchemy version.

This usually happens when one software calls specific functions from the other which are requiring specific version, otherwise those functions will not exists and therefore an exception will throw.

There is another discussion which describes the same problem

df to table throw error TypeError: __init__() got multiple values for argument 'schema'

It seems that the version 2.0.0 (realeased on January 26, 2023) of SQLAlchemy is not compatible with earlier versions of pandas.

Please consider always to include your software versions into original question and not only in comments, this will help to understand faster the problem.

Upvotes: 1

Yogesh Kushwaha
Yogesh Kushwaha

Reputation: 149

The issue started just when my package got updated. It is working on these fixed versions.

pandas==1.1.5 SQLAlchemy==1.4.45

Upvotes: 8

recacon
recacon

Reputation: 73

I just had this issue on Pandas 1.1.3 + SQLAlchemy 2.0.0. Updated to 1.5.3 and it was gone.

Upvotes: 6

Related Questions