I have a table from schema "test":
class AttributeConversion(Base):
__tablename__ = 'test.attribute_conversion'
How to select records from this table?
SQLAlchemy generates SQL:
select * from "test.attribute_conversion"
But it doesn't work. The correct query must be:
select * from test.attribute_conversion (without quotes)
The easiest way to find all tables in SQL is to query the INFORMATION_SCHEMA views. You do this by specifying the information schema, then the “tables” view. Here's an example. SELECT table_name, table_schema, table_type FROM information_schema.
1) Use the ALTER TABLE ... RENAME command and parameter to move the table to the target schema. 2) Use the CREATE TABLE ... CLONE command and parameter to clone the table in the target schema.
You can get a list of the schemas using an SSMS or T-SQL query. To do this in SSMS, you would connect to the SQL instance, expand the SQL database and view the schemas under the security folder. Alternatively, you could use the sys. schemas to get a list of database schemas and their respective owners.
You can explicity specify a schema name for a table:
class AttributeConversion(Base)
__tablename__ = 'attribute_conversion'
__table_args__ = {'schema' : 'test'}
See documentation on specifying the schema name.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With