Quoting sql queries with the DB-API

From: snacktime (snacktime_at_gmail.com)
Date: 01/24/05


Date: Sun, 23 Jan 2005 16:00:48 -0800
To: python-list@python.org

I'm used to using the perl DBI and not very familiar with the python
DB-API. I am using PyGreSQL. My question is what is the standard way
to quote strings in sql queries? I didn't see any quoting functions
in the DB-API docs. Is quoting handled internally by the PyGreSQL
module?

Also, is this a good way to use variables in an insert/update
statement, or is there a better way?

sql = "insert into test(a,b) values('%s','%s')" % (a,b)
cursor.execute(sql)

Chris



Relevant Pages

  • Re: Quoting sql queries with the DB-API
    ... > I'm used to using the perl DBI and not very familiar with the python ... > in the DB-API docs. ... Is quoting handled internally by the PyGreSQL ...
    (comp.lang.python)
  • Re: Python as replacement for PHP?
    ... That's an informational PEP, which implementations can follow or ignore ... Yes, but once you add such a module, you're no longer comparing PHP to ... You're comparing PHP to {Python plus some third party package ... the DB-API doesn't help you write code at all. ...
    (comp.lang.python)
  • Re: threads
    ... I was a math major, not a CS major. ... On a single CPU machine, threads will never improve the performance of a ... is the prime use of them in Python. ... Threads can be used to create a new API wrapped around DB-API which ...
    (comp.lang.python)
  • [ANN] Python API InformixDB-2.0 released
    ... to announce release 2.0 of the Informix implementation of the Python ... DB-API, a mere 5 weeks after release 1.5. ... many useful optional features suggested by the specification. ... backwards compatibility with version 1 of the DB-API specification. ...
    (comp.lang.python)
  • PyGreSQL 3.7 released
    ... PyGreSQL v3.7 has been released. ... PostgreSQL is a database system derived from Postgres4.2. ... Python is an interpreted programming language. ... PyGreSQL is a python module that interfaces to a PostgreSQL database. ...
    (comp.lang.python.announce)