<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          SQLAlchemyPython 數(shù)據(jù)持久層框架

          聯(lián)合創(chuàng)作 · 2023-09-30 04:09

          SQLAlchemy 是一個Python 的SQL 工具包以及數(shù)據(jù)庫對象映射框架。它包含整套企業(yè)級持久化模式,專門為高效和高性能的數(shù)據(jù)庫訪問。

          示例代碼:

          from sqlalchemy import Column, DateTime, String, Integer, ForeignKey, func
          from sqlalchemy.orm import relationship, backref
          from sqlalchemy.ext.declarative import declarative_base
           
          Base = declarative_base()
           
          class Department(Base):
              __tablename__ = 'department'
              id = Column(Integer, primary_key=True)
              name = Column(String)
           
          class Employee(Base):
              __tablename__ = 'employee'
              id = Column(Integer, primary_key=True)
              name = Column(String)
              # Use default=func.now() to set the default hiring time
              # of an Employee to be the current time when an
              # Employee record was created
              hired_on = Column(DateTime, default=func.now())
              department_id = Column(Integer, ForeignKey('department.id'))
              # Use cascade='delete,all' to propagate the deletion of a Department onto its Employees
              department = relationship(
                  Department,
                  backref=backref('employees',
                                   uselist=True,
                                   cascade='delete,all'))
           
          from sqlalchemy import create_engine
          engine = create_engine('sqlite:///orm_in_detail.sqlite')
           
          from sqlalchemy.orm import sessionmaker
          session = sessionmaker()
          session.configure(bind=engine)
          Base.metadata.create_all(engine)
          瀏覽 24
          點贊
          評論
          收藏
          分享

          手機掃一掃分享

          編輯 分享
          舉報
          評論
          圖片
          表情
          推薦
          點贊
          評論
          收藏
          分享

          手機掃一掃分享

          編輯 分享
          舉報
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  国产又粗又大操逼视频 | 无码精品人妻一区二区三区漫画 | 成人做爰黄 片免费 | 91小仙女jK白丝袜呻吟 | 在线观看欧美日韩aa |