Automap sqlalchemy.ext.automap 自动映射数据库表结构

from sqlalchemy.ext.automap import automap_base
from sqlalchemy.orm import Session
from sqlalchemy import create_engine

Base = automap_base()

# engine, suppose it has two tables 'user' and 'address' set up
engine = create_engine("mysql+mysqldb://wise:wise@172.31.238.141/wise?charset=utf8")

# reflect the tables
Base.prepare(engine, reflect=True)

# mapped classes are now created with names by default
# matching that of the table name.
User = Base.classes.user
Address = Base.classes.address


session = Session(engine)

# rudimentary relationships are produced
#session.add(Address(email_address="foo@bar.com", user=User(name="foo")))
#session.commit()

# collection-based relationships are by default named
# "<classname>_collection"

http://www.buluo360.com/

posted on 2017-08-30 10:35  TensorFlowNews  阅读(1009)  评论(0编辑  收藏  举报

TensorFlow

TensorFlow

磐创AI

TensorFlow 教程从入门到精通

TensorFlow 安装教程

Keras 从入门到精通

粒子群优化算法

聊天机器人

自然语言处理

TensorFlow

TensorFlow