You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
1020 B
26 lines
1020 B
6 months ago
|
from sqlalchemy import Column, Integer, String, create_engine
|
||
|
from sqlalchemy.ext.declarative import declarative_base
|
||
|
|
||
|
# 创建一个基类
|
||
|
Base = declarative_base()
|
||
|
|
||
|
|
||
|
class Channel(Base):
|
||
|
__tablename__ = 'Channel'
|
||
|
|
||
|
id = Column(Integer, primary_key=True, autoincrement=True)
|
||
|
channelId = Column(String(255), nullable=False)
|
||
|
channelTitle = Column(String(255), nullable=False)
|
||
|
channelLanguage = Column(String(255), nullable=False)
|
||
|
channelReptileTime = Column(String(255), nullable=True)
|
||
|
region = Column(String(255), nullable=True)
|
||
|
|
||
|
# 如果需要,可以在这里定义其他方法或属性
|
||
|
|
||
|
# 注意:这里只是定义了模型,并没有与数据库建立连接。
|
||
|
# 若要与数据库建立连接并创建表,你需要使用`create_engine`来创建一个数据库引擎,
|
||
|
# 然后使用`Base.metadata.create_all(engine)`来创建表。
|
||
|
# 例如:
|
||
|
# engine = create_engine('mysql+pymysql://user:password@localhost/your_database_name', echo=True)
|
||
|
# Base.metadata.create_all(engine)
|