使用sqlalchemy操作数据库
时间:2021-07-01 10:21:17
帮助过:17人阅读
from sqlalchemy
import create_engine, Column, Integer, String, DateTime, Float, Date, BLOB, func, ForeignKey, extract, and_, or_, text
2 from sqlalchemy.orm
import sessionmaker
3 from sqlalchemy.ext.declarative
import declarative_base
4
5 #创建基类
6 ModelBase =
declarative_base()
7
8 #创建映射表
9 class User(ModelBase):
10 __tablename__ =
‘user‘
11 id = Column(Integer, primary_key=True, autoincrement=True)
#自增主键
12 name = Column(String(80
))
13 createtime = Column(Datetime, index=True)
使用sqlalchemy操作数据库
标签:engine ESS time 常用 bsp 映射 ppi nbsp UNC