logo       


Choosing A Webhost:
A web hosting service is a type of Internet hosting service that allows individuals and organizations to provide their own website accessible via the World Wide Web. Web hosts are companies that provide space on a server they own for use by their clients as well as providing Internet connectivity, typically in a data center. Web hosts can also provide data center space and connectivity to the Internet for servers they do not own to be located in their data center, called colocation. more...

Formatting problem: msg#00014

Subject: Formatting problem

Hi all,

 

I have a problem with calling the execute method with a query that has a formatting operator in it. If I perform the substitution before calling the execute method, everything works. Am I doing something wrong?

 

Thanks for the help!

Jozsef

 

Test case:

 

In psql:

 

Create table test_table (id integer);

Insert into test_table values (1);

Insert into test_table values (2);

 

Now in python (v2.3):

 

import psycopg2

con = psycopg2.connect(‘dbname=test user=test’)

cur  = con.cursor()

 

cur.execute(‘select id from test_table where id in (%(ids)s)’, {‘ids’:’1, 2’})

Traceback (most recent call last):

  File "<stdin>", line 1, in ?

psycopg2._psycopg.ProgrammingError: invalid input syntax for integer: "1, 2"

 

# notice that this error is reported by psycopg not postgres, no need to abort the transaction

cur.execute(‘select id from test_table where id in (1, 2)’)

print cur.rowcount

2

 

 

 

 

 

 

_______________________________________________
Psycopg mailing list
Psycopg-IAPFreCvJWPBWskQ1e/+sw@xxxxxxxxxxxxxxxx
http://lists.initd.org/mailman/listinfo/psycopg
Ruby Jobs
Java Jobs
Jobs in California
more...
what
job title, keywords
where
city, state, zip
jobs by job search
<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
encryption.gpg....    ietf.rfc822/199...    freebsd.devel.i...    lang.haskell.li...    mail.squirrelma...    web.zope.plone....    yellowdog.gener...    text.xml.xalan....    recreation.phot...    kde.devel.educa...    hardware.bus.ca...    printing.ghosts...    voip.peering/20...    assembly/2006-0...    org.user-groups...    culture.interne...    network.i2p/200...    boot-loaders.ya...    xfree86.render/...    qnx.openqnx.dev...    jakarta.velocit...    user-groups.pal...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe