I am currently migrating an existing Python program that uses SQLAlchemy, but almost exclusively via using the SQLAlchemy engines for use in Pandas dataframes (e.g., pandas to_sql). Currently the connection strings used in creating the engine are those of another database (namely MySQL), and accessing databases (analogous to Postgres schemas) is easily done. How would I best specify the schema (and not merely the Postgres database which contains them) within a given engine?
Edit: Someone seems to have labeled this question as being a duplicate. It is not. I am not looking to auto-generate queries by using Sessions; I am looking to create connection strings in order to create SQLAlchemy engines for use in Pandas' to_sql function.
DataFrame.to_sql()takes the "default"schemato use as a keyword argument, if the underlying DB supports schemas. Your database - schema analog is misleading. Schemas separate objects to namespaces in a database, and a user can access all objects in different schemas in a DB (given perms).conargument toto_sql(). You'd reap the benefits of connection pooling etc. between calls. Also if using an engine instance instead of connection strings, the linked duplicate is actually valid, since you could then for example implement the connection event listener that sets the search path.