MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / _get_table_sql

Method _get_table_sql

lib/sqlalchemy/dialects/sqlite/base.py:2982–3008  ·  view source on GitHub ↗
(self, connection, table_name, schema=None, **kw)

Source from the content-addressed store, hash-verified

2980
2981 @reflection.cache
2982 def _get_table_sql(self, connection, table_name, schema=None, **kw):
2983 if schema:
2984 schema_expr = "%s." % (
2985 self.identifier_preparer.quote_identifier(schema)
2986 )
2987 else:
2988 schema_expr = ""
2989 try:
2990 s = (
2991 "SELECT sql FROM "
2992 " (SELECT * FROM %(schema)ssqlite_master UNION ALL "
2993 " SELECT * FROM %(schema)ssqlite_temp_master) "
2994 "WHERE name = ? "
2995 "AND type in ('table', 'view')" % {"schema": schema_expr}
2996 )
2997 rs = connection.exec_driver_sql(s, (table_name,))
2998 except exc.DBAPIError:
2999 s = (
3000 "SELECT sql FROM %(schema)ssqlite_master "
3001 "WHERE name = ? "
3002 "AND type in ('table', 'view')" % {"schema": schema_expr}
3003 )
3004 rs = connection.exec_driver_sql(s, (table_name,))
3005 value = rs.scalar()
3006 if value is None and not self._is_sys_table(table_name):
3007 raise exc.NoSuchTableError(f"{schema_expr}{table_name}")
3008 return value
3009
3010 def _get_table_pragma(self, connection, pragma, table_name, schema=None):
3011 quote = self.identifier_preparer.quote_identifier

Callers 5

get_columnsMethod · 0.95
get_pk_constraintMethod · 0.95
get_foreign_keysMethod · 0.95
get_check_constraintsMethod · 0.95

Calls 4

_is_sys_tableMethod · 0.95
quote_identifierMethod · 0.80
exec_driver_sqlMethod · 0.45
scalarMethod · 0.45

Tested by

no test coverage detected