logo       

Code does not work..is this a bug?: msg#00001

Subject: Code does not work..is this a bug?
This may be a bug?
The code works correctly from psql also pgAdminIII but not from python.  SUSE 
9.1 x86_64 , Python 2.3.3.  As you can see I'm using 1.99.10 (but it did not 
work with 1.1.15 either) Postgres 7.4.2

import psycopg
dsn= ......
conn = psycopg.connect(dsn)
crs = conn.cursor()
tablename = 'mytest'
crs.execute("SELECT cc.column_name AS fieldname, cc.data_type AS fieldtype, \
COALESCE(i.indisprimary,FALSE) AS is_pkey \
FROM information_schema.columns cc \
LEFT JOIN information_schema.key_column_usage cu \
ON (cc.table_name=cu.table_name AND cc.column_name=cu.column_name) \
LEFT JOIN pg_class cl ON(cl.relname=cu.table_name) \
LEFT JOIN pg_index i ON(cl.oid= i.indrelid) WHERE c.table_name= %s" % 
tablename)
rs=crs.fetchall()
print rs

sys:1: DeprecationWarning: Non-ASCII character '\xc2' in file newtest.py on 
line 6, but no encoding declared; see 
http://www.python.org/peps/pep-0263.html for details
[8817] initpsycopg: initializing psycopg 1.99.10
[8817] typecast_init: initializing NUMBER
[8817] typecast_new: typecast object created at 0x2a955d5900
[8817] typecast_add: object at 0x2a955d5900, values refcnt = 2
[8817] typecast_add:     adding val: 20
[8817] typecast_add:     adding val: 23
[8817] typecast_add:     adding val: 21
[8817] typecast_add:     adding val: 701
[8817] typecast_add:     adding val: 700
[8817] typecast_add:     adding val: 1700
[8817] typecast_init: initializing LONGINTEGER
[8817] typecast_new: typecast object created at 0x2a955d5930
[8817] typecast_add: object at 0x2a955d5930, values refcnt = 2
[8817] typecast_add:     adding val: 20
[8817] typecast_init: initializing INTEGER
[8817] typecast_new: typecast object created at 0x2a955d5990
[8817] typecast_add: object at 0x2a955d5990, values refcnt = 2
[8817] typecast_add:     adding val: 23
[8817] typecast_add:     adding val: 21
[8817] typecast_init: initializing FLOAT
[8817] typecast_new: typecast object created at 0x2a955d59f0
[8817] typecast_add: object at 0x2a955d59f0, values refcnt = 2
[8817] typecast_add:     adding val: 701
[8817] typecast_add:     adding val: 700
[8817] typecast_init: initializing DECIMAL
[8817] typecast_new: typecast object created at 0x2a955d5a50
[8817] typecast_add: object at 0x2a955d5a50, values refcnt = 2
[8817] typecast_add:     adding val: 1700
[8817] typecast_init: initializing UNICODE
[8817] typecast_new: typecast object created at 0x2a955d5ab0
[8817] typecast_add: object at 0x2a955d5ab0, values refcnt = 2
[8817] typecast_add:     adding val: 19
[8817] typecast_add:     adding val: 18
[8817] typecast_add:     adding val: 25
[8817] typecast_add:     adding val: 1042
[8817] typecast_add:     adding val: 1043
[8817] typecast_init: initializing STRING
[8817] typecast_new: typecast object created at 0x2a955d5b10
[8817] typecast_add: object at 0x2a955d5b10, values refcnt = 2
[8817] typecast_add:     adding val: 19
[8817] typecast_add:     adding val: 18
[8817] typecast_add:     adding val: 25
[8817] typecast_add:     adding val: 1042
[8817] typecast_add:     adding val: 1043
[8817] typecast_init: initializing BOOLEAN
[8817] typecast_new: typecast object created at 0x2a955d5b70
[8817] typecast_add: object at 0x2a955d5b70, values refcnt = 2
[8817] typecast_add:     adding val: 16
[8817] typecast_init: initializing DATETIME
[8817] typecast_new: typecast object created at 0x2a955d5bd0
[8817] typecast_add: object at 0x2a955d5bd0, values refcnt = 2
[8817] typecast_add:     adding val: 1114
[8817] typecast_add:     adding val: 1184
[8817] typecast_add:     adding val: 704
[8817] typecast_add:     adding val: 1186
[8817] typecast_init: initializing TIME
[8817] typecast_new: typecast object created at 0x2a955d5c30
[8817] typecast_add: object at 0x2a955d5c30, values refcnt = 2
[8817] typecast_add:     adding val: 1083
[8817] typecast_add:     adding val: 1266
[8817] typecast_init: initializing DATE
[8817] typecast_new: typecast object created at 0x2a955d5c90
[8817] typecast_add: object at 0x2a955d5c90, values refcnt = 2
[8817] typecast_add:     adding val: 1082
[8817] typecast_init: initializing INTERVAL
[8817] typecast_new: typecast object created at 0x2a955d5cf0
[8817] typecast_add: object at 0x2a955d5cf0, values refcnt = 2
[8817] typecast_add:     adding val: 704
[8817] typecast_add:     adding val: 1186
[8817] typecast_init: initializing BINARY
[8817] typecast_new: typecast object created at 0x2a955d5d50
[8817] typecast_add: object at 0x2a955d5d50, values refcnt = 2
[8817] typecast_add:     adding val: 17
[8817] typecast_init: initializing ROWID
[8817] typecast_new: typecast object created at 0x2a955d5db0
[8817] typecast_add: object at 0x2a955d5db0, values refcnt = 2
[8817] typecast_add:     adding val: 26
[8817] typecast_new: typecast object created at 0x2a955d5e10
[8817] typecast_init: initializing PYDATETIME
[8817] typecast_new: typecast object created at 0x2a955d5e40
[8817] typecast_init: initializing PYTIME
[8817] typecast_new: typecast object created at 0x2a955d5ea0
[8817] typecast_init: initializing PYDATE
[8817] typecast_new: typecast object created at 0x2a955d5f00
[8817] typecast_init: initializing PYINTERVAL
[8817] typecast_new: typecast object created at 0x2a955d5f30
[8817] microprotocols_add: cast 0x2a9630dba0 for (str, ?)
[8817] microprotocols_add: cast 0x2a9630dba0 for (unicode, ?)
[8817] microprotocols_add: cast 0x2a9630e020 for (buffer, ?)
[8817] microprotocols_add: cast 0x2a955db2d8 for (datetime.date, ?)
[8817] microprotocols_add: cast 0x2a955db320 for (datetime.time, ?)
[8817] microprotocols_add: cast 0x2a955db368 for (datetime.datetime, ?)
[8817] microprotocols_add: cast 0x2a955db3b0 for (datetime.timedelta, ?)
[8817] microprotocols_add: cast 0x2a9630de00 for (bool, ?)
[8817] initpsycopg: module initialization complete
[8817] psyco_connect: dsn = 'host=192.168.1.211 dbname=testpg user=johnf 
password=jfabiani '
[8817] connection_setup: init connection object at 0x2a955964b8, refcnt = 1
[8817] conn_connect: new postgresql connection at 0x55cbf0
[8817] conn_connect: using protocol 3
[8817] connection_setup: good connection object at 0x2a955964b8, refcnt = 1
[8817] psyco_conn_cursor: new cursor for connection at 0x2a955964b8
[8817] psyco_conn_cursor:     parameters: name = (null)
[8817] cursor_setup: init cursor object at 0x2a95580710, refcnt = 1
[8817] cursor_setup: good cursor object at 0x2a95580710, refcnt = 1
[8817] psyco_conn_cursor: new cursor at 0x2a95580710: refcnt = 1
[8817] psyco_curs_execute: starting execution of new query
[8817] curs_execute: pg connection at 0x55cbf0 OK
[8817] pq_begin: pgconn = 0x55cbf0, isolevel = 1, status = 1
[8817] pq_begin: issued 'BEGIN; SET TRANSACTION ISOLATION LEVEL READ 
COMMITTED' command
[8817] pq_execute: executing SYNC query:
[8817]     SELECT cc.column_name AS fieldname, cc.data_type AS fieldtype, 
COALESCE(i.indisprimary,FALSE) AS is_pkey FROM information_schema.columns cc 
LEFT JOIN information_schema.key_column_usage cu ON (cc.tab
[8817] pq_execute: entering syncronous DBAPI compatibility mode
[8817] pq_fetch: pgstatus = PGRES_FATAL_ERROR
[8817] pq_fetch: uh-oh, something FAILED
[8817] psyco_curs_execute: res = -1, pgres = (nil)
Traceback (most recent call last):
  File "newtest.py", line 6, in ?
    crs.execute("SELECT cc.column_name AS fieldname, cc.data_type AS 
fieldtype, \
psycopg.ProgrammingError: relation " cc" does not exist

[8817] cursor_dealloc: found myself in cursor list
[8817] cursor_dealloc: deleted cursor object at 0x2a95580710, refcnt = -1
[8817] pq_abort: pgconn = 0x55cbf0, isolevel = 1, status = 2
[8817] pq_abort: issued 'ABORT' command
[8817] conn_close: ophaning 0 cursors
[8817] conn_close: PQfinish called
[8817] connection_dealloc: deleted connection object at 0x2a955964b8, refcnt = 
0


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
boot-loaders.gr...    php.pear.genera...    debugging.valgr...    kde.redhat.user...    text.xml.xsl.ge...    culture.languag...    hardware.microc...    java.servicemix...    redhat.release....    web.zope.plone....    user-groups.lin...    opendarwin.webk...    video.mjpeg.use...    sysutils.bcfg2....    encryption.gpg....    lx-office.devel...    xfree86.forum/2...    mail.mutt.devel...    acpi.devel/2003...    qnx.openqnx.dev...    network.irc.irs...    freebsd.devel.m...   
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