'Is pandas to_sql() method allows us to specify database name

I created a sqlalchemy engine using the db as default_db

engine = sqlalchemy.create_engine('mysql+pymysql://username:password@hostname/default_db')

When I try to insert a record into a table test which is in db new_db using pandas to_sql(), It doesn't take the table name that specified with database.

result = dataFrame.to_sql(f"{new_db}.{test}", engine, index=False, if_exists='append')

result returned here is None.

Is there any way to specify different db in to_sql() method while engine created with some other db?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source