0

My code snipit

from flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy(app)
inspector = inspect(db.engine)

Viewing default schema

print('Default schema: ', inspector.default_schema_name)

list of all available Schema

print('schema: ', inspector.get_schema_names())

Output: Default schema: dbo

schema: ['admin', 'db_accessadmin', 'db_backupoperator', 'db_datareader', 'db_datawriter', 'db_ddladmin', 'db_denydatareader', 'db_denydatawriter', 'db_owner', 'db_securityadmin', 'dbo', 'devops', 'goal', 'etl', 'etl_logging', 'etl_on', 'evil', 'guest', 'INFORMATION_SCHEMA', 'location', 'search', 'search_json', 'semantic', 'sys', 'tms', 'tms_on', 'tvclient', 'util', 'abc', 'xyz']

I want to use abc schema. How do I do?

Anuj Subedi
  • 42
  • 1
  • 8
  • use scalar query with this command "SELECT SCHEMA_NAME()" this would give you the current schema name. Then, you can just use the returned name into your method. – iSR5 Aug 22 '18 at 08:19
  • It worked. Thanks @iSR5 But this gave me a current schema name. What I am looking for is to change the current schema. – Anuj Subedi Aug 23 '18 at 03:52
  • This might help https://stackoverflow.com/questions/15482838/change-schema-name-of-table-in-sql – iSR5 Aug 23 '18 at 05:17

0 Answers0