【问题标题】:Insert data in to mysql db using mysql.connector [duplicate]使用 mysql.connector 将数据插入到 mysql db [重复]
【发布时间】:2016-11-02 03:42:40
【问题描述】:

我正在尝试将一些数据插入“计费帐户”表中,并尝试了以下方式。没有错误,数据没有被插入到表中。我在这里做错什么了吗?我正在使用 python 的 mysql.connector 模块来完成这项工作。

def billingaccounts(self,stag,prod):

    print "Updating the consilidated daily bills for stag and prod"
    cursor = self.testdb.cursor()
    stag = 87
    prod = 45
    now = '2016-06-03'
    to = 84
    cursor.execute('INSERT INTO iaas.billing_accounts (date, staging_account, production_acount, total) VALUES (%s, %s, %s, %s)',(now,stag,prod,to))

【问题讨论】:

  • 我不知道这个特定的模块,但你确定它处于自动提交模式吗?还是不应该在插入后提交?
  • 非常感谢您的帮助

标签: python mysql-workbench mysql-python mysql-connector-python


【解决方案1】:

【讨论】:

  • 感谢您的帮助
猜你喜欢
  • 1970-01-01
  • 2020-04-01
  • 1970-01-01
  • 2015-07-14
  • 1970-01-01
  • 2018-08-03
  • 2021-07-08
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多