473,698 Members | 2,754 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

help: pypgsql: this code works in Fedora core 1, Not in FC2

Hello good people,

Following works in FC1 (python-2.2.3-7, postgresql-7.3.4-11,
kernel-2.4.22-1.2194.nptl, pyPgSQL-2.4)

from pyPgSQL import PgSQL
conn = PgSQL.connect(' localhost',data base='rop')
loccur = conn.cursor()
loccur.execute( "DECLARE itemcursor CURSOR FOR \
SELECT * FROM locmf")
loccur.execute( "FETCH ALL FROM itemcursor")
rec=loccur.fetc hall()
print rec

However, following errors are produced in FC2 (python-2.3.3-6,
postgresql-7.4.2-1, kernel-2.6.8-1.521, pyPgSQL-2.4):

/usr/lib/python2.3/site-packages/pyPgSQL/PgSQL.py:2644: FutureWarning:
%u/%o/%x/%X of negative int will return a signed string in Python 2.4
and up
name = "PgSQL_%08X " % id(self)
Traceback (most recent call last):
File "tt1.py", line 5, in ?
loccur.execute( "DECLARE itemcursor CURSOR FOR \
File "/usr/lib/python2.3/site-packages/pyPgSQL/PgSQL.py", line 3091,
in execute
self.res = self.conn.conn. query('FETCH 1 FROM "%s"' % self.name)
libpq.Operation alError: ERROR: cursor "PgSQL_F6F9906C " does not exist

Out of this, the first error is produced by conn.cursor() statement.

We have to use the "declare cursor" statement because we have to use
"fetch prior" statement later in the program. Is there a better way of
achiving this?

Something seems to have changed either python or in postgresql that is
causing this error. Can someone provide a solution/workaround?

Thanks in advance.
J Dubal.
Jul 18 '05 #1
2 1695
On Sun, 2004-09-26 at 00:41 -0700, J Dubal wrote:
Hello good people,

Following works in FC1 (python-2.2.3-7, postgresql-7.3.4-11,
kernel-2.4.22-1.2194.nptl, pyPgSQL-2.4)

from pyPgSQL import PgSQL
conn = PgSQL.connect(' localhost',data base='rop')
loccur = conn.cursor()
loccur.execute( "DECLARE itemcursor CURSOR FOR \
SELECT * FROM locmf")
loccur.execute( "FETCH ALL FROM itemcursor")
rec=loccur.fetc hall()
print rec

However, following errors are produced in FC2 (python-2.3.3-6,
postgresql-7.4.2-1, kernel-2.6.8-1.521, pyPgSQL-2.4):

/usr/lib/python2.3/site-packages/pyPgSQL/PgSQL.py:2644: FutureWarning:
%u/%o/%x/%X of negative int will return a signed string in Python 2.4
and up
name = "PgSQL_%08X " % id(self)
Traceback (most recent call last):
File "tt1.py", line 5, in ?
loccur.execute( "DECLARE itemcursor CURSOR FOR \
File "/usr/lib/python2.3/site-packages/pyPgSQL/PgSQL.py", line 3091,
in execute
self.res = self.conn.conn. query('FETCH 1 FROM "%s"' % self.name)
libpq.Operation alError: ERROR: cursor "PgSQL_F6F9906C " does not exist

Out of this, the first error is produced by conn.cursor() statement.

We have to use the "declare cursor" statement because we have to use
"fetch prior" statement later in the program. Is there a better way of
achiving this?

Something seems to have changed either python or in postgresql that is
causing this error. Can someone provide a solution/workaround?
Don't know if anything changed between the versions of the software you
are using, but see

http://www.postgresql.org/docs/curre...l-declare.html

particularly the section on "WITH HOLD/WITHOUT HOLD" and the first
paragraph in "Notes". I'm guessing that perhaps you aren't starting a
new transaction before declaring the cursor and that perhaps pyPgSQL is
autocommitting the DECLARE statement which would result in your declared
cursor going out of scope. Try adding WITH HOLD or put your stuff
inside of "BEGIN/COMMIT" statements.

Regards,
Cliff
Thanks in advance.
J Dubal.

--
Cliff Wells <cl************ @comcast.net>

Jul 18 '05 #2
Cliff Wells <cl************ @comcast.net> wrote in message news:<ma******* *************** *************** *@python.org>.. .
On Sun, 2004-09-26 at 00:41 -0700, J Dubal wrote:
Hello good people,

Following works in FC1 (python-2.2.3-7, postgresql-7.3.4-11,
kernel-2.4.22-1.2194.nptl, pyPgSQL-2.4)

from pyPgSQL import PgSQL
conn = PgSQL.connect(' localhost',data base='rop')
loccur = conn.cursor()
loccur.execute( "DECLARE itemcursor CURSOR FOR \
SELECT * FROM locmf")
loccur.execute( "FETCH ALL FROM itemcursor")
rec=loccur.fetc hall()
print rec

However, following errors are produced in FC2 (python-2.3.3-6,
postgresql-7.4.2-1, kernel-2.6.8-1.521, pyPgSQL-2.4):

/usr/lib/python2.3/site-packages/pyPgSQL/PgSQL.py:2644: FutureWarning:
%u/%o/%x/%X of negative int will return a signed string in Python 2.4
and up
name = "PgSQL_%08X " % id(self)
Traceback (most recent call last):
File "tt1.py", line 5, in ?
loccur.execute( "DECLARE itemcursor CURSOR FOR \
File "/usr/lib/python2.3/site-packages/pyPgSQL/PgSQL.py", line 3091,
in execute
self.res = self.conn.conn. query('FETCH 1 FROM "%s"' % self.name)
libpq.Operation alError: ERROR: cursor "PgSQL_F6F9906C " does not exist

Out of this, the first error is produced by conn.cursor() statement.

We have to use the "declare cursor" statement because we have to use
"fetch prior" statement later in the program. Is there a better way of
achiving this?

Something seems to have changed either python or in postgresql that is
causing this error. Can someone provide a solution/workaround?


Don't know if anything changed between the versions of the software you
are using, but see

http://www.postgresql.org/docs/curre...l-declare.html

particularly the section on "WITH HOLD/WITHOUT HOLD" and the first
paragraph in "Notes". I'm guessing that perhaps you aren't starting a
new transaction before declaring the cursor and that perhaps pyPgSQL is
autocommitting the DECLARE statement which would result in your declared
cursor going out of scope. Try adding WITH HOLD or put your stuff
inside of "BEGIN/COMMIT" statements.

Regards,
Cliff
Thanks in advance.
J Dubal.


Many thanks for your response. We tried a few things and found that
although the above code does not work on FC2, it works if we change
this statement:
conn = PgSQL.connect(' localhost',data base='rop')
to this:
conn = PgSQL.connect(' 192.168.1.5',da tabase='rop')
192.168.1.5 happens to be another host running redhat 8.0 and
postgresql-server-7.3.4-1PGDG. It appears that the older (7.3.4)
engine was allowing the above syntax but the newer (7.4.2) is not
allowing.

Then we tried conn.conn.toggl eShowQuery. This shows what sql
statements are executed. Based on its output we worked out the
following solution. Relace these lines:
loccur.execute( "DECLARE itemcursor CURSOR FOR \
SELECT * FROM locmf")
loccur.execute( "FETCH ALL FROM itemcursor")
by these lines:
loccur.execute( "SELECT * FROM locmf")
curname=loccur. name
loccur.execute( 'FETCH ALL FROM "%s"' %curname)

Then everything works as expected. Even with the old engine.
Thanks and regards.
J Dubal.
Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2772
by: Paolo Alexis Falcone | last post by:
Whenever I try to access a table with many rows using PgSQL's fetchall(), this happens: >>> from pyPgSQL import PgSQL >>> db = PgSQL.connect("192.168.0.8:5432:whitegold","dondon","dondon") >>> PgSQL.NoPostgresCursor = 1 >>> cur = db.cursor() >>> cur.execute("SELECT * FROM customer") >>> data = cur.fetchall() Traceback (most recent call last):
2
3598
by: Rene Pijlman | last post by:
I can't seem to find any way to specify the character encoding with the DB API implementation of PyPgSQL. There is no mention of encoding and Unicode in the DB API v2.0 spec and the PyPgSQL README. When I have Unicode strings in Python and store it in a PostgreSQL Unicode database, will the data automatically be correctly encoded? Or do I need to specify the UTF-8 client encoding on the database connection somehow? I'm using the...
2
1385
by: Frank Millman | last post by:
Hi all Below is the text of a message I was about to send in connection with an obscure problem. I have now almost got to the bottom of it, and am fairly confident that it is a bug in pyPgSQL. I hope this is the correct place to report such bugs. If not, please advise the correct forum. I have left the original message intact as it provides important information. At the bottom, I have recorded the new information that I
5
2180
by: linuxfreak | last post by:
Hi guys, Has anyone installed wxPython on Fedora Core 4. Apparently it need the libstdc++.so.5 file while Fedora installs the newer libstdc++.so.6 file. I tried installing the libstdc rpm from fedora core 3 which would have installed the required file but Fedora does not allow multiple versions of the same file . Man this is frustrating. Help desparately required..........
5
2994
by: Craig Keightley | last post by:
Please help, i have attached my page which worksin IE but i cannnot get the drop down menu to fucntion in firefox. Any one have any ideas why? Many Thanks Craig <<<<<<<<<<<<<<CODE>>>>>>>>>>>>>>>> <html>
1
1827
by: Boris Popov | last post by:
Hello pgsql-general, It appears 7.4 is not published in all the usual places so I was wondering if there's a yum repository with updated packages available and if not then what's the approach that will cause the least amount of pain? I do realize I'll need to dump/restore, just want some expert advice on how to upgrade the installation without breaking it. Thanks!
4
2655
by: Philip Wright | last post by:
Can we install the admin client for DB2 7.2 on Fedora Core 4? Thanks, PW
2
2216
by: Raffounz | last post by:
Hi everyone, I've installed Fedora Core 5 and SuSe 10.1 on my laptop, installed glib and ortp 0.7.1, run ./configure with success, but when I type make after a while I receive this error: if /bin/sh ../../libtool --silent --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I../.. -DPOSIX -g -O2 -MT socketadapters.lo -MD -MP -MF ".deps/socketadapters.Tpo" -c -o socketadapters.lo socketadapters.cc; \ then mv -f ".deps/socketadapters.Tpo"...
15
2953
by: John Nagle | last post by:
I've been installing Python and its supporting packages on a dedicated server with Fedora Core 6 for about a day now. This is a standard dedicated rackmount server in a colocation facility, controlled via Plesk control panel, and turned over to me with Fedora Core 6 in an empty state. This is the standard way you get a server in a colo today. Bringing Python up in this completely clean environment is a huge hassle, and it doesn't...
0
8683
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8609
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9170
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8871
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7739
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4371
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2336
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.