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 6357525
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:10:55+00:00 2026-05-24T23:10:55+00:00

I am connected to postgresql with sqlalchemy. When I try this code: e =

  • 0

I am connected to postgresql with sqlalchemy. When I try this code:

e = create_engine('')
r = e.execute("select ?", 5)

it gives me:

sqlalchemy.exc.ProgrammingError: (ProgrammingError) syntax error at end of input

Corresponding to http://www.sqlalchemy.org/docs/core/connections.html?highlight=engine#sqlalchemy.engine.base.Connection.execute there are different types of paramstyles…
After deeper research, i found out that default paramstyle for postgresql Dialect is “pyformat”.

Can somebody show me how to use this pyformat on some example?
I would just like to use placeholders or named placeholders for forming up the sql statement.

I tried:

e.execute("select %s, %s;", "test", "test2")

But this is not working either.

Thank you

edit:
of course, i am passing valid connection string to create_engine method 🙂

  • 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-05-24T23:10:56+00:00Added an answer on May 24, 2026 at 11:10 pm

    The documentation you link to, directly links to PEP 249, which shows you the different styles.

    About pyformat it says:

    ‘pyformat’ Python extended format codes, e.g. ‘…WHERE
    name=%(name)s’

    So that’s what you need to use.

    By Googling on “DBAPI pyformat” the second link is the link to the psycopg2 documentation. After mentioning that it uses pyformat there is a “See Also” linking to a page with loads of examples.

    Examples of how to use it are in your original link:

    e.execute("select %s, %s;", ("param1", "test"), ("param2", "test2"))
    

    You can also use this syntax:

    e.execute("select %(param1)s, %(param2)s;", param1="test", param2="test2"))
    

    Which is nicer.

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

Sidebar

Related Questions

How can you get the active users connected to a postgreSQL database via SQL?
Consider the following snippet of Python code: from sqlalchemy import * from sqlalchemy.orm import
I'm developing an application in c# .NET that is connected to a PostgreSQL database
When connected to a postgresql database using psycopg and I pull the network cable
I updated a database table using postgresql from python My code was import psycopg2
Im trying to use Postgresql with Play for their Yabe tutorial and get this
I am trying to connect to a postgreSQL db with the following code. <?php
I want to develop an application to connect to a PostgreSQL Database, I want
I currently have an MS Access application that connects to a PostgreSQL database via
I have connected to a server via SFTP using FileZilla and accepted adding the

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.