我正试图用psycopg2向我的表插入数值。我的插入查询有列名,我正在使用.format方法将变量插入值中。我得到的错误如下......似乎它使用了我的电子邮件中的 "test "字符串作为一个列。当我删除电子邮件列,只留下account_number时,它只插入了部分随机数字,而不是'123456789'......。我不知道为什么?
我得到了一个错误。
" VALUES ({},{})""".format(account2, email2))
psycopg2.errors.UndefinedTable: missing FROM-clause entry for table
"test"
LINE 2: VALUES (123456789,test@example.com)
我也曾尝试使用"%"格式,看看是否是我的.format方式将数值插入到查询中,但这也没有用。
elif extrareadayday_date in extrareaddays:
accounts_sheet = pd.read_excel("C:\\Users\\bxt058y\\PycharmProjects\\MSIT501\\MSIT\\sumbaccounts.xlsx",
sheet_name=0)
df = DataFrame(accounts_sheet)
email_address2 = df[df['cycle_day'] == current_cycle_day].email_address_test
account_numbers2 = df[df['cycle_day'] == current_cycle_day].account_number
email_address3 = df[df['cycle_day'] == current_cycle_day2].email_address_test
account_numbers3 = df[df['cycle_day'] == current_cycle_day2].account_number
for account2, email2 in zip(account_numbers2, email_address2):
to_file(sumbstatementfilepath, account2, 'N - NOT BILLED', 'SUMB_Statement_{}.txt'.format(account2.strip()), email2)
print(account2)
extra_read_day_confirmation_email()
cursor.execute("""INSERT INTO sumb_email_conf (account_number, email_address)
VALUES ({},{})""".format(account2, email2))
for account3, email3 in zip(account_numbers3, email_address3):
to_file(sumbstatementfilepathreadday, account3, 'N - NOT BILLED', 'SUMB_Statement_{}.txt'.format(account3.strip()),
email3)
print(account3)
extra_read_day_confirmation_email2()
cursor.execute("""INSERT INTO sumb_email_conf (account_number,email_address)
VALUES ({},{})""".format(account3, email3))
connection.commit()