我正在阅读Essential SQLALchemy 2nd。
以下代码是从本书中复制的
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Table, Column, Integer, Numeric, String, Boolean
Base = declarative_base()
class Cookie(Base):
__tablename__ = 'cookies'
cookie_id = Column(Integer(), primary_key=True)
cookie_name = Column(String(50), index=True)
cookie_recipe_url = Column(String(255))
cookie_sku = Column(String(55))
quantity = Column(Integer())
unit_cost = Column(Numeric(12, 2))
Cookie.__table__
书中的结果是
表格(' cookies',MetaData(bind =无),列(' cookie_id',Integer(),table =,primary_key = True,nullable = False),列( ' cookie_name',字符串(长度= 50),表=),列(' cookie_recipe_url',字符串(长度= 255),表=),列(' cookie_sku&# 39;,字符串(长度= 55),表格=),列('数量',整数(),表格=),列(' unit_cost',数字(精度= 12, scale = 2),table =),schema = None)