Pipeline to load data from python to mysql

I am going to build the pipeline to load data from python to mysql but there is error

> enginesa = create_engine(f'mysql://{db_params["user"]}:{db_params["password"]}@{db_params["host"]}/{db_params["database"]}', connect_args={'options': '-csearch_path={}'.format("sa")})
>     enginedw = create_engine(f'mysql://{db_params["user"]}:{db_params["password"]}@{db_params["host"]}/{db_params["database"]}', connect_args={'options': '-csearch_path={}'.format("dw")})

TypeError: Connection.init() got an unexpected keyword argument ā€˜options’

Please help!
Python Help

The error seems to be explained succinctly in the message: the value you’re passing to connect_args includes the key options, which is not a valid keyword for Connection.__init__() (presumably, connect_args is getting passed into that).

Without any other details, it’s hard to say more. What packages are you using here? Where did create_engine come from?

Thanks for your reply.

I used from sqlalchemy import create_engine, text
and tried many different ways to fix this issue

pip install sqlalchemy
pip install pymysql.

it’s huge data file, so i don’t know how to put here. Please let me know if you need more info.

I don’t need the data. I just need you to read the error message and connect it to the docs for SQLAlchemy.

When you call create_engine, you gave it connect_args={'options': ...}. Looking at the docs, it says

Looking at the docs for pymysql.connections.Connection, we can look at the signature, and it’s clear that there’s no keyword named ā€œoptionsā€ there. There also isn’t anything named search_path, so I’m not sure what you’re attempting there. Perhaps one of the available options is what you want. Perhaps you don’t need that option at all. Why are you including it?

1 Like