Previous topic

stalker.db.engine

Next topic

stalker.db.query

This Page

stalker.db.metadata

stalker.db.metadata

A collection of Tables and their associated schema constructs.

Holds a collection of Tables and an optional binding to an Engine or Connection. If bound, the Table objects in the collection and their columns may participate in implicit SQL execution.

The Table objects themselves are stored in the metadata.tables dictionary.

The bind property may be assigned to dynamically. A common pattern is to start unbound and then bind later when an engine is available:

metadata = MetaData()
# define tables
Table('mytable', metadata, ...)
# connect to an engine later, perhaps after loading a URL from a
# configuration file
metadata.bind = an_engine

MetaData is a thread-safe object after tables have been explicitly defined or loaded via reflection.