Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9198727
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:21:18+00:00 2026-06-17T22:21:18+00:00

I am currently trying to use place holders in my PostgreSQL query within Python’s

  • 0

I am currently trying to use place holders in my PostgreSQL query within Python’s psycopg’s module. Here is a sample of the code I am using.

table.execute('SELECT * FROM table WHERE col2 = %s ORDER BY pID ASC LIMIT %s OFFSET %s;',(val1,val2,val3))

I read somewhere that it is not possible to use placeholders like this for LIMIT and OFFSET however I should use this placeholder format for WHERE =.

safely specifying 'order by' clause from user input in python / postgresql / psycopg2

Does anyone know the proper placeholder syntax for this sql query? Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T22:21:20+00:00Added an answer on June 17, 2026 at 10:21 pm

    Limit and offset can both be used with placeholders without any issue.

    Generally speaking you can use placeholders wherever a ‘value’ would be allowed in an expression.

    cur.execute("select * from node where node_name = %s limit %s offset %s", ('test', 5, 5))

    Works just fine.

    As already noted in the referenced article you cannot use placeholders to refer to tables, columns, schemas, or aliases for any of them. In those cases you generally need to do your own variable substitution before calling execute.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently trying to use AJAX in my application via jRails. I am
I'm currently trying to use the latest stable fmod ex in my project. I
I am currently trying to use this gem http://github.com/pengwynn/linkedin . Everything works fine (i.e.
So i am running into a major issue. I am currently trying to use
I'm having trouble editing an XML file. I'm currently trying to use Nokogiri ,
Currently I am trying to use a bunch of custom perl modules, test.pm as
currently i'm trying to use imagick to generate some images without saving them on
What I am currently trying to do is use the Face API to detect
I am currently trying to research how to use Android with an existing java
I'm a beginner coder in Ruby and currently I'm trying to use this plugin:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.