【问题标题】:django-orm : How can I insert element to a table of a particular databasedjango-orm:如何将元素插入到特定数据库的表中
【发布时间】:2017-02-19 03:47:35
【问题描述】:

我在 setting.py 中有 2 个不同的数据库。 要执行选择操作,我使用以下语句并且工作正常:

all_data = Bugs.objects.using('database_one').filter(reporter=user_id, bug_status='resolved', resolution__in=all_resolutions)[:2]

但是如何传递数据库值以在同一数据库的表中插入条目。

我试过了,但这似乎不起作用:

row_to_be_added = TableName(pr=pr, case=case, comments=comments).using('bugzilla').save()

谁能帮帮我。

【问题讨论】:

    标签: python mysql django django-orm


    【解决方案1】:

    来自docs

    row_to_be_added = TableName(pr=pr, case=case, comments=comments).save(using='bugzilla')
    

    【讨论】:

      猜你喜欢
      • 2020-03-24
      • 1970-01-01
      • 2011-03-22
      • 1970-01-01
      • 1970-01-01
      • 2021-08-16
      • 2023-04-10
      • 2011-12-24
      相关资源
      最近更新 更多