Python Forum
python variable in SQL query
Thread Rating:
  • 1 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
python variable in SQL query
#6
(Nov-23-2017, 10:01 AM)buran Wrote: from the docs
Quote: 
  • The placeholder must not be quoted. Psycopg will add quotes where needed:
    >>> cur.execute("INSERT INTO numbers VALUES ('%s')", (10,)) # WRONG
    >>> cur.execute("INSERT INTO numbers VALUES (%s)", (10,)) # correct


Thanks!, stupid I missed it
Reply


Messages In This Thread
python variable in SQL query - by takaa - Nov-22-2017, 09:30 PM
RE: python variable in SQL query - by micseydel - Nov-22-2017, 10:11 PM
RE: python variable in SQL query - by micseydel - Nov-22-2017, 10:12 PM
RE: python variable in SQL query - by takaa - Nov-23-2017, 09:52 AM
RE: python variable in SQL query - by buran - Nov-23-2017, 10:01 AM
RE: python variable in SQL query - by takaa - Nov-23-2017, 10:12 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  list the files using query in python arjunaram 0 1,084 Mar-28-2023, 02:39 PM
Last Post: arjunaram
  python sql query single quote in a string mg24 1 2,079 Nov-18-2022, 08:01 PM
Last Post: deanhystad
  "SUMIF" type query in Python (help required) BlainEillimatta 0 1,461 Oct-06-2022, 09:08 AM
Last Post: BlainEillimatta
  MSSQL query not working in Python kat35601 0 1,477 Apr-12-2022, 06:44 PM
Last Post: kat35601
  Error using mariadb select query with form in python? shams 2 2,831 Jul-29-2021, 12:30 PM
Last Post: shams
  Python mysql query help please tduckman 4 5,512 Mar-13-2020, 03:42 PM
Last Post: Marbelous
  SQL query with a variable amount of parameters Antares 10 9,615 Jul-08-2019, 02:24 PM
Last Post: Antares
  Add Variable to select query UtiliseIT 2 3,340 May-03-2019, 11:45 AM
Last Post: UtiliseIT
  SQLite Query in Python rowyourboat 2 3,493 Apr-26-2019, 02:24 PM
Last Post: Larz60+
  Python Turtle and order of implementation query Parsleigh 2 3,429 Mar-04-2019, 02:43 PM
Last Post: Parsleigh

Forum Jump:

User Panel Messages

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