PostgreSQL 7.4.1和pgdb.py [英] PostgreSQL 7.4.1 and pgdb.py

查看:82
本文介绍了PostgreSQL 7.4.1和pgdb.py的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我的盒子:RedHat 9.0,Pentium III

最近我从PostgreSQL 7.3.2升级到PostgreSQL 7.4.1。

PostgreSQL 7.3.2'的rpms是从RehHat CD安装的

我用来升级的PostgreSQL 7.4.1的rpms是从RHEL3下载的

子目录(镜像
ftp://ftp4.ar.postgresql.org/pub/mir.../redhat/rhel3)


升级运行良好,即使我可以从PHP

脚本连接到PostgreSQL。


升级之前,我曾经使用pgdb.py连接到PostgresQL(

PyGreSQL随附一个rpms我猜)。我在交互式shell中使用

的sintaxis是:


---------------

import pgdb
dbConnect = pgdb.connect(dsn =''localhost:oracle'',user =''manuel'',
password ='''')cursor = dbConnect.cursor()
cursor.execute(" select * from address")
while(1):
.... row = cursor.fetchone()

.... if row == None:

.... break

....打印行

....

[''BAILEY'',''WILLIAM'',无,无,无,无,'''213-293-0223 '',无]

[''ADAMS'',''JACK'',无,无,无,无,''415-453-7330'',无]

-

-cursor.close()
dbConnect.close()
------------------ -----


正如你所看到的,连接和fechting都是成功的。


但现在当我输入相同的sintaxis wi新安装(PostgreSQL

7.4.1),当我输入四行时出错:


-------- -------- import pgdb
dbConnect = pgdb.connect(dsn =''localhost:oracle'',user =''manuel'',
password ='''')游标= dbConnect.cursor()
cursor.execute(" select * from address")



Traceback(最近一次调用最后一次):

文件"< stdin>",第1行,在?

文件" /usr/lib/python2.2/site-packages/pgdb.py" ;,第189行,执行

self.executemany(操作,(params,))

文件" /usr/lib/python2.2/site-packages/ pgdb.py",第221行,在executemany

desc = type [1:2] + self ._cache.getdescr(typ [2])

文件" / usr / lib / python2.2 / site-packages / pgdb.py",第149行,在getdescr中

self ._source.execute(

_pg.error:错误:不存在列typprtlen

------------- -----


顺便提一下地址表中列的类型是:

lastname varchar(25)

firstname varchar(25)

street varchar(30)

city varchar(15)

state varchar(2)

zip int

phone varchar(12)

ext varchar(5)


我的问题:


-Anybody知道为什么我不能使用pgdb.py模块连接到PostgreSQL

现在?

- 也许sintaxis已经改变了?

Manuel Tejada

---------------------------(播出结束) ---------------------------

提示8:解释分析是你的朋友

解决方案

> >>> cursor.execute(" select * from address")

Traceback(最近一次调用最后一次):
文件"< stdin>",第1行,在?
文件/usr/lib/python2.2/site-packages/pgdb.py" ;,第189行,执行
self.executemany(操作,(params,))
文件" /usr/lib/python2.2/site-packages/pgdb.py" ;,第221行,在executemany中
desc = type [1:2] + self ._cache.getdescr(typ [2 ])
文件" /usr/lib/python2.2/site-packages/pgdb.py" ;,第149行,在getdescr
self ._source.execute(
_pg.error:错误:不存在列typprtlen




这是系统目录表中的一列(以pg_开头)。

pgdb.py必须尝试访问系统的过时版本

目录。


您可能会获得更新的pgdb。不知何故,或者你可以使用

" import pg"它有一个差异erent接口(非DBAPI-2.0兼容)

但应该可以正常工作(因为它不会尝试访问系统目录,

它更低用于python的-level PG接口。


简而言之,pgdb.py中存在问题,它试图在外部访问

信息-bate方式。


问候,

杰夫戴维斯



------ ---------------------(广播结束)------------------------ ---

提示2:您可以使用取消注册命令一次性取消所有列表

(发送取消注册YourEmailAddressHere; ma*******@postgresql.org


2004年1月30日星期五07:42:27 -0800,Jeff Davis写道:

你可能会以某种方式获得更新的pgdb.py ,或者你可以使用
import pg它具有不同的接口(非DBAPI-2.0兼容)
但应该可以正常工作(因为它不会尝试访问系统目录,
它更像是一个低级PG接口python)。




请记住,就Python而言,还有psycopg和PyGreSql

接口。


-

Alvaro Herrera(< alvherre [a] dcc.uchile.cl>)

" Pido que me den el Nobel por razones humanitarias (Nicanor Parra)


---------------------------(播出结束) - -------------------------

提示2:你可以使用unregister命令立即取消所有列表

(发送取消注册YourEmailAddressHere到 ma ******* @ postgresql.org


>请记住,还有psycopg和PyGreSql,就像Python

接口而言。




函数使得在python中使用它很自然),和pgdb.py是

PyGreSQL的兼容DBAPI-2.0的接口,它与python中的其他

接口兼容(所以你可以为PostgreSQL换掉另一个数据库)

没有代码更改,理想情况下。


pgdb.py,符合DBAPI-2.0规范,做匹配的事情

数据类型通过使用系统目录(所以你不必转换

从文本),并有更多的功能,使它更自然地

与python一起使用。但是,随着每个版本的更改,pgdb.py需要更新以更新以匹配postgres目录的当前版本,这是海报遇到的问题。

。我认为在某些方面它应该类似于

JDBC。


我通常使用pg.py,所以我可能有一些细节错误关于pgdb.py.


问候,

杰夫戴维斯

------------- --------------(广播结束)---------------------------

提示9:如果您的

加入列的数据类型不匹配,计划员将忽略您选择索引扫描的愿望


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(dsn=''localhost:oracle'', user=''manuel'', password='''')cursor = dbConnect.cursor()
cursor.execute("select * from address")
while (1): .... row = cursor.fetchone()
.... if row == None:
.... break
.... print row
....
[''BAILEY'',''WILLIAM'',None,None,None,None,''213-293-0223'',None]
[''ADAMS'',''JACK'',None,None,None,None,''415-453-7330'',None]
-
-cursor.close()
dbConnect.close() -----------------------

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

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

----------------import pgdb
dbConnect = pgdb.connect(dsn=''localhost:oracle'', user=''manuel'', password='''')cursor = dbConnect.cursor()
cursor.execute("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.executemany(operation, (params,))
File "/usr/lib/python2.2/site-packages/pgdb.py", line 221, in executemany
desc = type[1:2]+self ._cache.getdescr(typ[2])
File "/usr/lib/python2.2/site-packages/pgdb.py", line 149, in getdescr
self ._source.execute(
_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

解决方案

> >>>cursor.execute("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.executemany(operation, (params,))
File "/usr/lib/python2.2/site-packages/pgdb.py", line 221, in executemany
desc = type[1:2]+self ._cache.getdescr(typ[2])
File "/usr/lib/python2.2/site-packages/pgdb.py", line 149, in getdescr
self ._source.execute(
_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 YourEmailAddressHere" to ma*******@postgresql.org)


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 YourEmailAddressHere" to ma*******@postgresql.org)


> 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


这篇关于PostgreSQL 7.4.1和pgdb.py的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆