Python Forum
mysql.connector - incorrect integer value
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
mysql.connector - incorrect integer value
#4
(May-28-2017, 10:25 AM)Milo Wrote: Ok so I had a quick look at it again and the below seems to work as expected.

Well, no.  That's using string formatting and manual quoting, which bypasses mysql's sanitation.  So it works, but only if nobody ever tries to break your database.
This is the way you should be doing it:
cursor.execute("INSERT INTO schedule (gid) VALUES (%s)", (value, ))
More examples can be found in the docs: https://dev.mysql.com/doc/connector-pyth...elect.html
Reply


Messages In This Thread
mysql.connector - incorrect integer value - by Milo - May-27-2017, 09:22 AM
RE: mysql.connector - incorrect integer value - by nilamo - Aug-14-2017, 06:29 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Question No disconnect method for snowflake.connector ? Calab 0 164 Jun-11-2024, 09:42 PM
Last Post: Calab
  Mysql and mysql.connector error lostintime 2 866 Oct-03-2023, 10:25 PM
Last Post: lostintime
  Code is returning the incorrect values. syntax error 007sonic 6 1,514 Jun-19-2023, 03:35 AM
Last Post: 007sonic
  error 1102 (42000) incorrect database name 's' Anldra12 4 1,838 Jun-08-2022, 09:00 AM
Last Post: Anldra12
  Mysql error message: Lost connection to MySQL server during query tomtom 6 16,907 Feb-09-2022, 09:55 AM
Last Post: ibreeden
Question Debian 11 Bullseye | Python 3.9.x | pip install mysql-connector-python-rf problems BrandonKastning 4 6,992 Feb-05-2022, 08:25 PM
Last Post: BrandonKastning
  mysql.connector.errors.ProgrammingError: Failed processing format-parameters; Python ilknurg 3 5,964 Jan-18-2022, 06:25 PM
Last Post: ilknurg
  Program stuck at mysql.connector.connect zazas321 1 2,177 Jul-29-2021, 10:49 AM
Last Post: zazas321
  MYSQL.CONNECTOR ERROR DB1 8 4,123 Jul-23-2021, 03:31 AM
Last Post: DB1
  openpyxl incorrect delete rows VladislavM 6 4,414 Jul-19-2021, 08:54 AM
Last Post: VladislavM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020