标签:无法 integer ring classes 模块 sql val log rom
class Foo(Bar):
def __init__():
pass
from sqlalchemy.ext.declarative import declarative_base Base = declarative_base() class HotWordType(Base): # 表名称 __tablename__ = ‘hotWordType‘ # id typeName id = Column(Integer, primary_key=True) # 主键 typeName = Column(String(20), nullable=False) # 类型名 hotWord = relationship(‘HotWord‘, backref=‘hotWordType‘)
declarative_base 中的元类源码:
The new base class will be given a metaclass that produces appropriate :class:`~sqlalchemy.schema.Table` objects and makes the appropriate :func:`~sqlalchemy.orm.mapper` calls based on the information provided declaratively in the class and any subclasses of the class. class DeclarativeMeta(type): def __init__(cls, classname, bases, dict_): if ‘_decl_class_registry‘ not in cls.__dict__: _as_declarative(cls, classname, cls.__dict__) type.__init__(cls, classname, bases, dict_) def __setattr__(cls, key, value): _add_attribute(cls, key, value)
标签:无法 integer ring classes 模块 sql val log rom
原文地址:http://www.cnblogs.com/suyuan1573/p/6031893.html