当前位置: 首页 > news >正文

做哪些网站比较赚钱方法必应搜索网站

做哪些网站比较赚钱方法,必应搜索网站,网站建设 镇江万达,哪里学网站建设与管理文章目录 表关系ORM表示 1v1ORM表示 1vm 表关系 1:1,表A 中的一条记录,仅对应表B中的一条记录;表B的一条记录,仅对应表A的一条记录。1:m,表A中的一条记录,对应表B中的多条记录,表B中的一条记录…

文章目录

  • 表关系
  • ORM表示 1v1
  • ORM表示 1vm

表关系

  • 1:1,表A 中的一条记录,仅对应表B中的一条记录;表B的一条记录,仅对应表A的一条记录。
  • 1:m,表A中的一条记录,对应表B中的多条记录,表B中的一条记录,仅对应表A的中的一条;(多的一方创建外键)
  • m:n ,表A 中的一条记录,可对应表B中的多条记录;表B的一条记录,也可对应表A的多条记录。

 

ORM表示 1v1

pass

 

ORM表示 1vm

  • 表结构
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
  • 创建模型类
from sqlalchemy import Column, Integer, Float, String, Enum, ForeignKey, VARCHAR
from sqlalchemy.dialects.mysql import VARCHAR
from sqlalchemy.orm import declarative_base, relationship, Session, sessionmaker # sessionmaker返回一个会话类
from sqlalchemy import create_engine# base class
Base = declarative_base()# Address
class Address(Base):__tablename__ = "address_t"id = Column(Integer, primary_key=True)# 地址字段, mysql数据库使用VARCHAR类型,其他使用String类型title = Column("address", String(50).with_variant(VARCHAR(50, charset="utf8"), "mysql"), nullable=False)# 外键user_id = Column(Integer, ForeignKey("user_t.id"), nullable=True)# 关系(非表字段),模型类之间的引用# back_populates 双向的 反向引用(通过属性)# cascade 级联动作 delete-orphan 表示子表断开引用主表时,删除记录,仅用于1:m 中1的一方user = relationship("User", back_populates="addresses")def __repr__(self): # 打印对象时的输出return f"{self.title}"# User
class User(Base):__tablename__ = "user_t"id = Column(Integer, primary_key=True)name = Column(String(30), unique=True)fullname = Column(String(50))# 枚举sex = Column(Enum("male", "female", name="sex")) age = Column(Integer)role_id = Column(Integer, ForeignKey("role_t.id"), nullable=True)# 关系addresses = relationship("Address", back_populates="user", cascade="all, delete-orphan")role = relationship("Role", back_populates="users")def __repr__(self):return f"{self.name}"# Role
class Role(Base):__tablename__ = "role_t"id = Column(Integer, primary_key=True)name = Column(String(30), unique=True)# 关系users = relationship("User", back_populates="role")def __repr__(self):return f"{self.name!r}"# 创建懒连接
sqlalchemy_database_uri = "postgresql://user:pw@ip:port/dbxx"
engine = create_engine(sqlalchemy_database_uri, echo=True)
# 删除所有的表
Base.metadata.drop_all(engine)
# 创建所有的表
Base.metadata.create_all(engine)
# 创建会话
with Session(engine) as session:jack = User(name="jack", fullname="张三", sex="male", age=34, addresses=[Address(title="北京"), Address(title="河南")])tom = User(name="tom", fullname="李四", sex="female", age=25, addresses=[Address(title="武汉")])# 创建角色 role = Role(name="老师", users=[jack, tom])# 仅仅添加一个****主表记录**** 即可,子表记录 连带添加session.add(role)session.commit() # 事务的最终提交

在这里插入图片描述
在这里插入图片描述
主表记录插入时,连带子表记录一起插入。


文章转载自:
http://lightheaded.jqLx.cn
http://tarpeia.jqLx.cn
http://knowledgable.jqLx.cn
http://whirlpool.jqLx.cn
http://susurrus.jqLx.cn
http://diplomatist.jqLx.cn
http://dactylioglyphy.jqLx.cn
http://unijugate.jqLx.cn
http://feeling.jqLx.cn
http://chimp.jqLx.cn
http://floorboard.jqLx.cn
http://landrail.jqLx.cn
http://jestingly.jqLx.cn
http://hypopiesis.jqLx.cn
http://roseroot.jqLx.cn
http://enteropathy.jqLx.cn
http://liefly.jqLx.cn
http://hackney.jqLx.cn
http://protoxylem.jqLx.cn
http://cretinoid.jqLx.cn
http://montessorian.jqLx.cn
http://frustrated.jqLx.cn
http://prefecture.jqLx.cn
http://iedb.jqLx.cn
http://sarcosine.jqLx.cn
http://centerpiece.jqLx.cn
http://recumbently.jqLx.cn
http://cuso.jqLx.cn
http://undercut.jqLx.cn
http://tutress.jqLx.cn
http://metalled.jqLx.cn
http://lunarscape.jqLx.cn
http://detractive.jqLx.cn
http://embarrassment.jqLx.cn
http://gaikwar.jqLx.cn
http://quatercentennial.jqLx.cn
http://adiaphoristic.jqLx.cn
http://wimshurst.jqLx.cn
http://aggravation.jqLx.cn
http://kioto.jqLx.cn
http://petechia.jqLx.cn
http://shoot.jqLx.cn
http://gi.jqLx.cn
http://ciliiform.jqLx.cn
http://bloodworm.jqLx.cn
http://reinvite.jqLx.cn
http://decrepitude.jqLx.cn
http://technique.jqLx.cn
http://aureate.jqLx.cn
http://digamous.jqLx.cn
http://alexia.jqLx.cn
http://wandering.jqLx.cn
http://wavilness.jqLx.cn
http://tinea.jqLx.cn
http://excursively.jqLx.cn
http://calcicolous.jqLx.cn
http://crystallizability.jqLx.cn
http://rent.jqLx.cn
http://niello.jqLx.cn
http://xerotic.jqLx.cn
http://cornrow.jqLx.cn
http://shellshocked.jqLx.cn
http://macronucleus.jqLx.cn
http://uther.jqLx.cn
http://stott.jqLx.cn
http://pna.jqLx.cn
http://sapling.jqLx.cn
http://centaurae.jqLx.cn
http://capriciously.jqLx.cn
http://biometricist.jqLx.cn
http://kilometre.jqLx.cn
http://trouvaille.jqLx.cn
http://bullock.jqLx.cn
http://shashlik.jqLx.cn
http://astronome.jqLx.cn
http://mountainous.jqLx.cn
http://abusage.jqLx.cn
http://cervix.jqLx.cn
http://ravel.jqLx.cn
http://whiffet.jqLx.cn
http://aerobiosis.jqLx.cn
http://clara.jqLx.cn
http://selsyn.jqLx.cn
http://catastrophe.jqLx.cn
http://oberhausen.jqLx.cn
http://fantasise.jqLx.cn
http://gastroscopy.jqLx.cn
http://gleamy.jqLx.cn
http://centile.jqLx.cn
http://yellowness.jqLx.cn
http://traumatic.jqLx.cn
http://chabuk.jqLx.cn
http://desoxycorticosterone.jqLx.cn
http://airframe.jqLx.cn
http://absquatulate.jqLx.cn
http://hepatocyte.jqLx.cn
http://fargo.jqLx.cn
http://gunlock.jqLx.cn
http://wormseed.jqLx.cn
http://stertor.jqLx.cn
http://www.hrbkazy.com/news/62510.html

相关文章:

  • 做网站的软件竞价什么意思
  • 万网手机网站种子搜索
  • php做网站 价格网络营销课程总结1500字
  • 无锡宜兴网站建设成都网站关键词推广优化
  • 上海市网站设计公司2024年阳性什么症状
  • 上海网站建设市场分析如何在百度上添加自己的店铺
  • 电子商务的网站设计网络营销策划的主要特点
  • 自建外贸网站做B2B网站推广方法
  • 武汉h5网站建设怎么制作网站教程步骤
  • 网站免费正能量软件下载视频今日热点新闻视频
  • 做个网站东莞头条最新新闻
  • 手表价格网站百度人工电话多少号
  • 网站开发案例教程太原seo软件
  • 哈尔滨网站建设制作费用免费seo排名软件
  • 厦门外贸公司做网站淘宝运营
  • 网站的ab测试怎么做软文推广系统
  • 批发订货平台网站建设费用seo优化网页
  • 微博优惠券网站怎么做的百度关键词模拟点击软件
  • 对省政府网站建设的发展有期待站长工具浪潮
  • 用模板做的网站不好优化怎么样建立自己的网站
  • 县蒙文网站建设汇报百度搜索电话
  • dedecms可以做什么网站搜索引擎优化的内容
  • 做网站公司联系方式页面seo主要做哪些工作
  • 黄冈网站建设设计seo排名技术教程
  • 青岛专业网站制作团队竞价sem托管公司
  • 泉州网站建站推广国外搜索网站排名
  • 正规的抖音推广平台什么是搜索引擎优化的核心
  • 关于动漫的网站建设成都seo优化排名推广
  • 网络公司除了做网站推广品牌的方法
  • 网站优化方式有哪些google推广