转载请标明地址https://blog.youkuaiyun.com/weixin_42068117/article/details/83857355
https://github.com/zzzeek/sqlalchemy/blob/master/lib/sqlalchemy/sql/schema.py
"""Symbol indicating that a :class:`.Table` or :class:`.Sequence`
should have 'None' for its schema, even if the parent
:class:`.MetaData` has specified a schema.
.. versionadded:: 1.0.14
"""
def _get_table_key(name, schema):
if schema is None:
return name
else:
return schema + "." + name
这一段代码显示的是我们给定的schema会拼接数据库的名字。大家应该可以理解是 数据库.表名 这样就不会有数据库的限制。这一段属于示例给大家理解的,如果只想知道怎么用,直接看本文最后的代码示例就可以了。
class Table(DialectKWArgs, SchemaItem, TableClause):
"""
The :class:`.Table` object constructs a unique instance of itself based
on its name and optional schema name within the given
:class:`.MetaData` object. Calling the :class:`.Table`
constructor with the same name and same :class:`.MetaData` argument
a second time will return the *same* :class:`.Table` object - in this way
the :class:`.Table` constructor acts as a registry function.
:param schema: The schema name for this table, which is required if
the table resides in a schema other than the default selected schema
for the engine's database connection. Defaults to ``None``.
If the owning :class:`.MetaData` of this :class:`.Table` specifies
its own :paramref:`.MetaData.schema` parameter, then that schema