473,563 Members | 2,797 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PostgreSQL 7.4.1 and pgdb.py

Hi
My box: RedHat 9.0, Pentium III

Recently I upgraded from PostgreSQL 7.3.2 to PostgreSQL 7.4.1.
The PostgreSQL 7.3.2's rpms were installed from RehHat CDs
The PostgreSQL 7.4.1's rpms I used to upgrade were downloaded from RHEL3
subdirectory (of the mirror
ftp://ftp4.ar.postgresql.org/pub/mir.../redhat/rhel3).

The upgrade is working well, even I can connect to PostgreSQL from a PHP
script.

Before upgrading I used to connect to PostgresQL using pgdb.py (part of
PyGreSQL that comes with one of the rpms I guess). The sintaxis I was using
from interactive shell were:

---------------
import pgdb
dbConnect = pgdb.connect(ds n='localhost:or acle', user='manuel', password='')cursor = dbConnect.curso r()
cursor.execu te("select * from address")
while (1): .... row = cursor.fetchone ()
.... if row == None:
.... break
.... print row
....
['BAILEY','WILLI AM',None,None,N one,None,'213-293-0223',None]
['ADAMS','JACK', None,None,None, None,'415-453-7330',None]
-
-cursor.close ()
dbConnect.cl ose() -----------------------

As you can see, the connection and fechting were successful.

But now when I input the same sintaxis with the new Installation(Po stgreSQL
7.4.1), I get an error when I enter rhe four line:

----------------import pgdb
dbConnect = pgdb.connect(ds n='localhost:or acle', user='manuel', password='')cursor = dbConnect.curso r()
cursor.execu te("select * from address")

Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib/python2.2/site-packages/pgdb.py", line 189, in execute
self.executeman y(operation, (params,))
File "/usr/lib/python2.2/site-packages/pgdb.py", line 221, in executemany
desc = type[1:2]+self ._cache.getdesc r(typ[2])
File "/usr/lib/python2.2/site-packages/pgdb.py", line 149, in getdescr
self ._source.execut e(
_pg.error: ERROR: non exist the column "typprtlen"
------------------

By the way the types of columns from address table are:
lastname varchar(25)
firstname varchar(25)
street varchar(30)
city varchar(15)
state varchar(2)
zip int
phone varchar(12)
ext varchar(5)

My questions:

-Anybody knows why I can't connect to PostgreSQL using the pgdb.py module
now?
- Perhaps the sintaxis has changed?
Manuel Tejada
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Nov 22 '05 #1
14 4080
> >>>cursor.execu te("select * from address")
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib/python2.2/site-packages/pgdb.py", line 189, in execute
self.executeman y(operation, (params,))
File "/usr/lib/python2.2/site-packages/pgdb.py", line 221, in executemany
desc = type[1:2]+self ._cache.getdesc r(typ[2])
File "/usr/lib/python2.2/site-packages/pgdb.py", line 149, in getdescr
self ._source.execut e(
_pg.error: ERROR: non exist the column "typprtlen"


That's a column in a system catalog table (starts with "pg_"). The
pgdb.py must be trying to access an out of date version of the system
catalog.

You can probably get an updated pgdb.py somehow, or you can just use
"import pg" which has a different interface (non DBAPI-2.0 compliant)
but should work fine (since it doesn't try to access system catalogs,
it's more of a low-level PG interface for python).

In short, the problem exists in pgdb.py, which is trying to access
information in an out-of-date way.

Regards,
Jeff Davis


---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddres sHere" to ma*******@postg resql.org)

Nov 22 '05 #2
On Fri, Jan 30, 2004 at 07:42:27PM -0800, Jeff Davis wrote:
You can probably get an updated pgdb.py somehow, or you can just use
"import pg" which has a different interface (non DBAPI-2.0 compliant)
but should work fine (since it doesn't try to access system catalogs,
it's more of a low-level PG interface for python).


Keep in mind that there's also psycopg and PyGreSql, as far as Python
interfaces go.

--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"Pido que me den el Nobel por razones humanitarias" (Nicanor Parra)

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddres sHere" to ma*******@postg resql.org)

Nov 22 '05 #3
> Keep in mind that there's also psycopg and PyGreSql, as far as Python
interfaces go.


pg.py and pgdb.py are both part of PyGreSQL. pg.py is the more low-level
interface, closer to a wrapper of libpq (but with lots of helper
functions to make it natural to use in python), and pgdb.py is
PyGreSQL's DBAPI-2.0-compliant interface, which is compatible with other
interfaces in python (so you could swap out another DB for PostgreSQL
without code changes, ideally).

pgdb.py, in compliance with the DBAPI-2.0 spec, does things like match
data types up by using the system catalogs (so you don't have to convert
from text) and has even more features to make it even more natural to
use with python. However, with each version change, pgdb.py needs to be
updated to match the current version of the postgres catalogs, which is
the problem the poster ran into. I think it's supposed to be similar to
JDBC in some respects.

I usually use pg.py, so I might have some details wrong about pgdb.py.

Regards,
Jeff Davis
---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Nov 22 '05 #4
"Manuel Tejada" <ma*****@terra. com.pe> writes:
But now when I input the same sintaxis with the new Installation(Po stgreSQL
7.4.1), I get an error when I enter rhe four line: _pg.error: ERROR: non exist the column "typprtlen"


I believe this indicates you're using an old version of the PyGreSQL
module. typprtlen disappeared from the pg_type system catalog several
releases back. There is updated PyGreSQL code out there, but I'm not
very sure where --- have you looked at gborg.postgresq l.org?

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddres sHere" to ma*******@postg resql.org)

Nov 22 '05 #5
Old version of the PyGreSQL?

Remember I said that I made un apgrade to PostgreSQL version 7.4.1.
One of rpms I used to upgrade is the postgresql-python-7.4.1-1PGDG.i386.rpm.
I suppose that this come with the last version of PyGreSQL.

The README file in /usr/share/doc/postgresql-python-7.4.1 tells that the
module PyGreSQL is version 3.4. This version is the last according to
ftp://ftp.druid.net/pub/distrib/

When I use the module C or the module pg.py of PyGreSQL to connect with
PostgreSQL, they work fine.

But I would like to use the pgdb.py too

----- Original Message -----
From: "Tom Lane" <tg*@sss.pgh.pa .us>
To: "Manuel Tejada" <ma*****@terra. com.pe>
Cc: <pg***********@ postgresql.org>
Sent: Friday, January 30, 2004 11:41 PM
Subject: Re: [GENERAL] PostgreSQL 7.4.1 and pgdb.py

"Manuel Tejada" <ma*****@terra. com.pe> writes:
But now when I input the same sintaxis with the new Installation(Po stgreSQL 7.4.1), I get an error when I enter rhe four line:

_pg.error: ERROR: non exist the column "typprtlen"


I believe this indicates you're using an old version of the PyGreSQL
module. typprtlen disappeared from the pg_type system catalog several
releases back. There is updated PyGreSQL code out there, but I'm not
very sure where --- have you looked at gborg.postgresq l.org?

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Nov 22 '05 #6
Manuel Tejada wrote:
import pgdb
dbConnect = pgdb.connect(ds n='localhost:or acle', user='manuel',
password='')
cursor = dbConnect.curso r()
cursor.exec ute("select * from address")


Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib/python2.2/site-packages/pgdb.py", line 189, in execute
self.executeman y(operation, (params,))
File "/usr/lib/python2.2/site-packages/pgdb.py", line 221, in executemany
desc = type[1:2]+self ._cache.getdesc r(typ[2])
File "/usr/lib/python2.2/site-packages/pgdb.py", line 149, in getdescr
self ._source.execut e(
_pg.error: ERROR: non exist the column "typprtlen"
------------------


This is a really old problem already solved on 7.3 see this my post:

http://archives.postgresql.org/pgsql...2/msg00082.php

I'm checking that my 7.4.1 installation is affected by the same
problem. I don't understand how this could happen that a modification
made on a 7.3 was not ported to 7.4

For the moment what you can do is substitute this select:

"SELECT typname, typprtlen, typlen "
"FROM pg_type WHERE oid = %s" % oid

inside the file pgdb.py with this one:

"SELECT typname, 4, typlen "
"FROM pg_type WHERE oid = %s" % oid

just to not break all file.

I'm not able to look at CVS to see where the modification was lost.

Regards
Gaetano Mendola

Nov 22 '05 #7
Tom Lane wrote:
"Manuel Tejada" <ma*****@terra. com.pe> writes:
But now when I input the same sintaxis with the new Installation(Po stgreSQL
7.4.1), I get an error when I enter rhe four line:


_pg.error: ERROR: non exist the column "typprtlen"

I believe this indicates you're using an old version of the PyGreSQL
module. typprtlen disappeared from the pg_type system catalog several
releases back. There is updated PyGreSQL code out there, but I'm not
very sure where --- have you looked at gborg.postgresq l.org?


Unfortunately the pgdb.py is wrong and is shipped with

postgresql-python-7.4.1-1PGDG.i386.rpm

this problem was solved already on 7.3

look this:

http://archives.postgresql.org/pgsql...2/msg00082.php

something did wrong during the SRPM file building for the 7.4.1

Is a good idea look how this happen.


Regards
Gaetano Mendola
Nov 22 '05 #8
Thank you very much Gaetano

I edited the pgdb.py file setting "4" instead of "typprtlen" .
Now I am able to connect to PostgreSQL using pgdb.py.

Just for curiosity, Can I set to -1 too as Gerhard Haring told to you?
----- Original Message -----
From: "Gaetano Mendola" <me*****@bigfoo t.com>
Newsgroups: comp.databases. postgresql.gene ral
Cc: "Manuel Tejada" <ma*****@terra. com.pe>
Sent: Sunday, February 01, 2004 4:48 PM
Subject: Re: PostgreSQL 7.4.1 and pgdb.py

Manuel Tejada wrote:
>import pgdb
>dbConnect = pgdb.connect(ds n='localhost:or acle', user='manuel',


password='')
>cursor = dbConnect.curso r()
>cursor.exec ute("select * from address")


Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib/python2.2/site-packages/pgdb.py", line 189, in execute
self.executeman y(operation, (params,))
File "/usr/lib/python2.2/site-packages/pgdb.py", line 221, in executemany desc = type[1:2]+self ._cache.getdesc r(typ[2])
File "/usr/lib/python2.2/site-packages/pgdb.py", line 149, in getdescr self ._source.execut e(
_pg.error: ERROR: non exist the column "typprtlen"
------------------


This is a really old problem already solved on 7.3 see this my post:

http://archives.postgresql.org/pgsql...2/msg00082.php

I'm checking that my 7.4.1 installation is affected by the same
problem. I don't understand how this could happen that a modification
made on a 7.3 was not ported to 7.4

For the moment what you can do is substitute this select:

"SELECT typname, typprtlen, typlen "
"FROM pg_type WHERE oid = %s" % oid

inside the file pgdb.py with this one:

"SELECT typname, 4, typlen "
"FROM pg_type WHERE oid = %s" % oid

just to not break all file.

I'm not able to look at CVS to see where the modification was lost.

Regards
Gaetano Mendola

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Nov 22 '05 #9
Manuel Tejada wrote:
Thank you very much Gaetano

I edited the pgdb.py file setting "4" instead of "typprtlen" .
Now I am able to connect to PostgreSQL using pgdb.py.

Just for curiosity, Can I set to -1 too as Gerhard Haring told to you?


I think yes, I really didn't dig on it to see the usage of that
value.
Regards
Gaetano Mendola


Nov 22 '05 #10

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

Similar topics

4
5803
by: Chuck Amadi | last post by:
Hi all Anyone know a good Pygresql Tutorial for Interfacing between Python & Postgresql . Cheers Chuck
4
3618
by: Lance Hoffmeyer | last post by:
Hello, I am trying to learn some basics of python. One of the things I want to do is write a script to access a postgresql database DB as user USER with password PW and SELECT first_name, last_name, birthday FROM contacts print to the screen and then disconnect.
2
1943
by: Mage | last post by:
Hello, I started to write my PostgreSQL layer. I tried pyPgSQL and PyGreSQL. I made a *very minimal* performance test and comparsion with the same thing in php. Table "movie" has 129 record and many fields. I found PyGreSQL / DB-API / fetchall horrible slow (32 sec in my test). PHP did 13 secs and it gave the result in associative array....
1
1861
by: Ram | last post by:
Dear All I am very new to python . i would appreciate any help from you all on this problem which i am facing. I am trying to connect to postgres from python.for this i am using something like " import pgdb". i am able to connect to postgres and fetch data , if i execute the python file directly in unix prompt. However when i try to do...
0
1211
by: James Saker | last post by:
Just curious if anyone's aware of a good recipe for setting up SSL access to postgresql for pgdb (or another appropriate db-sig 2 compliant module). Or any good recommendations/considerations e.g. m2crypto with pgdb. jamie
3
1673
by: artistlikeu | last post by:
i have connected database with python program.... this program is simulation using Simpy. i call all simulation data from Postgresql using pgdb. is it possible that i can send some of results by using SQL queries back in the database. if is any hint plz??? regards
3
3202
by: dpholmes | last post by:
hi everyone, i'm very new to python and to this forum. i'm actually just trying to work through the tutorial on webpy.org. so far, so good, but as i tried to incorporate a postgresql database into the demo web app i'm receiving this error print out: Traceback (most recent call last): File...
3
2213
by: SteveD | last post by:
Hi guys, http://luaforge.net/frs/?group_id=327 pgdb.zip is an addition to scite-debug, which adds source debugging to the popular SciTE programmer's editor. gdbpy.zip is a standalone version which can be run from Emacs. These allow you to single-step from Python to C code in a debugger session.
1
3134
by: Johannes Bauer | last post by:
Hello group, I've run into a small problem with pgdb which is actually not PostgreSQL specific - I just do not understand the Python syntax at one point. I'm trying to initialize a connection to a PG database. So help(pgdb) says: pgdb.connect(connect_string) -connection connect_string = 'host:database:user:password:opt:tty' All parts...
0
7665
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...
0
7583
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...
0
8106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7642
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5484
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1200
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
924
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.