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

  • Home
  • SEARCH
  • 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 6629381
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:15:08+00:00 2026-05-25T22:15:08+00:00

Python has all sort of libraries to interface with databases, which provide a nice

  • 0

Python has all sort of libraries to interface with databases, which provide a nice way to build SQL queries without worrying about SQL injections. For instance, with sqlite3:

for t in [('2006-03-28', 'BUY', 'IBM', 1000, 45.00),
          ('2006-04-05', 'BUY', 'MSOFT', 1000, 72.00),
          ('2006-04-06', 'SELL', 'IBM', 500, 53.00),
         ]:
    c.execute('insert into stocks values (?,?,?,?,?)', t)

The trouble is, I don’t want to execute the query, I just want to format it and get the query as a string. I guess I could escape things myself, but it’s not a very elegant solution. There has to be a way to get the formatted queries without actually connecting to a database and running them.

(The context is that I’m writing a filter which prepares a series of SQL statements from the input, but I don’t want to run them on a specific database, just save them for later.)

  • 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-25T22:15:09+00:00Added an answer on May 25, 2026 at 10:15 pm

    There has to be a way to get the formatted queries without actually connecting to a database and running them

    Not really.

    The RDBMS handles this internally with “prepared queries” and “bind variables”. The “formatted” doesn’t actually exist. Anywhere.

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

Sidebar

Related Questions

Python has a lot of GUI libraries: tkinter, wxWidgets, pyGTK etc. But all these
I would like create my own collection that has all the attributes of python
Python has this wonderful way of handling string substitutions using dictionaries: >>> 'The %(site)s
Python has a built in function sum , which is effectively equivalent to: def
I'm currently busy making a Python ORM which gets all of its information from
Python has a singleton called NotImplemented . Why would someone want to ever return
Python has an ordered dictionary . What about an ordered set?
Python has a flag -O that you can execute the interpreter with. The option
Background Python has "textwrap" and "dedent" functions. They do pretty much what you expect
So Python has positive and negative infinity: float(inf), float(-inf) This just seems like 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.