账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    python slqalchemy
    57
    0

    A 模型有数据 a1
    B 模型有数据 b1

    b1.key1 是外键,关联a1.id 的主键

    现在我直接删除a1数据有问题吗?
    db.session.delete(a1)
    db.session.commit()

    0
    打赏
    收藏
    点击回答
        全部回答
    • 0
    • 洒了囚心酒 普通会员 1楼

      SQLAlchemy is a Python library for working with databases, and it provides a high-level abstraction for interacting with databases. It is based on SQLAlchemy's Object-Relational Mapping (ORM) framework, which allows developers to use Python code instead of writing SQL queries. With SQLAlchemy, you can perform a wide range of database operations, such as creating, reading, updating, and deleting data. SQLAlchemy also provides support for database migrations, which allows you to create and apply changes to your database schema over time. To get started with SQLAlchemy, you will first need to install it using pip. You can install SQLAlchemy by running the following command in your terminal or command prompt: pip install sqlalchemy

      Once SQLAlchemy is installed, you can import it into your Python code using the following statement: python from sqlalchemy import create_engine, Column, Integer, String

      This will create a database engine object that you can use to connect to a database and perform database operations. For example, to connect to a MySQL database, you can use the following code: python engine = create_engine('mysql://user:password@localhost/dbname')

      This will create a database engine object that you can use to connect to the specified database and perform database operations. Overall, SQLAlchemy is a powerful and flexible library for working with databases in Python, and it is a popular choice for many developers.

    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部