search

Home  >  Q&A  >  body text

python - SQLAlchemy如何设置外键却不加约束来使用关系?

就是写关系的时候必须要在属性上加有ForeignKey,但是能不能不加约束,仅仅指定外键就使用SQLAlchemy的relationship

PHP中文网PHP中文网2812 days ago539

reply all(3)I'll reply

  • 天蓬老师

    天蓬老师2017-04-18 10:13:07

    Since you don’t need constraints, why do you need foreign keys? ? ? Just set a field to store the corresponding relationship

    reply
    0
  • PHPz

    PHPz2017-04-18 10:13:07

    Adding foreign keys can maintain data integrity, and you can also set up relationships yourself. That kind of control is easy to use

    reply
    0
  • 迷茫

    迷茫2017-04-18 10:13:07

    In Python, you can use properties directly instead of foreign keys, but you need to do more work yourself

    reply
    0
  • Cancelreply