2022-03-02 sqlalchemy 模块时遇到困惑的问题

在 python 中使用 sqlalchemy 时, 不要忘了建模, 不管是查询还是更新或创建表格都需要建模; 现举例如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/urs/bin/env python3
# filename: 1.py


from sqlalchemy import Column, String, create_engine, Integer
from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.declarative import declarative_base

Base = declarative_base()

def class student(Base):
id = Column(Integer)
name = Column(String(20))
age = Column(Integer(20))




2022-03-02 sqlalchemy 模块时遇到困惑的问题
https://www.supermew.top/2022/03/02/sqlalchemy-模块时遇到困惑的问题/
作者
八月
发布于
2022年3月2日
许可协议