Q
Q
qwertiss2021-07-09 14:39:38
MySQL
qwertiss, 2021-07-09 14:39:38

Error when querying to add a row in mysql?

nick = fir + ' ' + sec
null = 0
mo = 1
tnull='none'
data_insert = (peid, usid, fir, sec, nick, null, null, null, null, null, null, null, null, null, mo, mo, mo, mo, mo, mo, mo, mo, mo, mo, mo, mo, mo, null, tnull, mo, mo, mo, mo, mo, mo)
zapros_insert = "INSERT INTO users (chat_id, user_id, first_name, second_name, nick, rp_white, level, last_level, is_ban, permission, money, bitcoin, last_mining_cash, last_price_cash, mining_start, mining_server_1, mining_server_2, mining_server_3, mining_server_pro_1, mining_server_pro_2, mining_server_pro_3, mining_server_ultra_1, mining_server_ultra_2, mining_server_ultra_3, mining_datacenter_1, mining_datacenter_2, mining_datacenter_3, mining_first_kapital, message_id, case_tier_common, case_tier_uncommon, case_tier_rare, case_tier_epic, case_tier_legendary, case_tier_mythical) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
cur.execute(zapros_insert, data_insert)
con.commit()

Shows an error on startup

File "Vk_bot.py", line 4479, in
main(event)
File "Vk_bot.py", line 441, in main
cur.execute(zapros_insert, data_insert)
TypeError: not all arguments converted during string formatting

In sqlite3, everything worked fine, but when switching to mysql, it began to complain.
How to fix?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
o5a, 2021-07-09
@qwertiss

For substitution in mysql instead of ? use %s
AND the number of wildcards must match the number of elements in data_insert.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question