473,569 Members | 2,737 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

OverflowError in pyPgSQL when accessing tables with many rows

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:543 2:whitegold","d ondon","dondon" )
PgSQL.NoPostgre sCursor = 1
cur = db.cursor()
cur.execute("SE LECT * FROM customer")
data = cur.fetchall()

Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib/python2.2/site-packages/pyPgSQL/PgSQL.py", line 3106,
in fetchall
return self.__fetchMan yRows(self._row s_, _list)
File "/usr/lib/python2.2/site-packages/pyPgSQL/PgSQL.py", line 2684,
in __fetchManyRows
_j = self.__fetchOne Row()
File "/usr/lib/python2.2/site-packages/pyPgSQL/PgSQL.py", line 2660,
in __fetchOneRow
_r.getvalue(sel f._idx_, _i)))
File "/usr/lib/python2.2/site-packages/pyPgSQL/PgSQL.py", line 717,
in typecast
return PgNumeric(value , _p, _s)
File "/usr/lib/python2.2/site-packages/pyPgSQL/PgSQL.py", line 1335,
in __init__
raise OverflowError, "value too large for PgNumeric"
OverflowError: value too large for PgNumeric

The aforementioned table, customer, only has 1023 entries with the
following structure:

CREATE TABLE customer (ccustcode varchar(80), cgroupcode varchar(10),
clastname varchar(80), cfirstname varchar(80), cmi varchar(10),
ccompany varchar(80), caddress1 varchar(80), caddress2 varchar(80),
ccity varchar(80), cprovince varchar(80), czipcode varchar(10), iterms
integer, ycredit_limit numeric, npenalty_rate numeric,
default_routeco de varchar(10), lisdirector boolean);

PgSQL's fetchone() fortunately works though, as well as using
fetchall() on tables with few rows. Is there any alternative way of
using PyPgSQL that would not overflow in this situation?

My test system is on Debian Sid with the following python and
postgresql package versions:
ii postgresql 7.3.3-1 Object-relational SQL database,
descended fr
ii postgresql-cli 7.3.3-1 Front-end programs for PostgreSQL
ii postgresql-con 7.3.3-1 Additional facilities for PostgreSQL
ii python2.2 2.2.3-2.1 An interactive high-level
object-oriented la
ii python2.2-egen 2.0.4-1 Date and time handling routines for
Python 2
ii python2.2-egen 2.0.4-1 A collection of new builtins for
Python 2.2
ii python2.2-nume 23.0-5 Numerical (matrix-oriented)
Mathematics for
ii python2.2-nume 23.0-5 Extension modules for Numeric Python
ii python2.2-pgsq 2.3.0-2 A Python DB-API 2.0 interface to
PostgreSQL

--> paolo

Paolo Alexis Falcone
pf******@free.n et.ph
Jul 18 '05 #1
3 2765
Paolo Alexis Falcone wrote:
Whenever I try to access a table with many rows using PgSQL's
fetchall(), this happens:
First, I'd recommend you ask on the pyPgSQL mailing list in such cases.
Otherwise it might happen that the pyPgSQL developers miss a post on the
newsgroup :-)
from pyPgSQL import PgSQL
db = PgSQL.connect(" 192.168.0.8:543 2:whitegold","d ondon","dondon" )
PgSQL.NoPos tgresCursor = 1
cur = db.cursor()
cur.execute ("SELECT * FROM customer")
data = cur.fetchall()


Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib/python2.2/site-packages/pyPgSQL/PgSQL.py", line 3106,
in fetchall
return self.__fetchMan yRows(self._row s_, _list)
File "/usr/lib/python2.2/site-packages/pyPgSQL/PgSQL.py", line 2684,
in __fetchManyRows
_j = self.__fetchOne Row()
File "/usr/lib/python2.2/site-packages/pyPgSQL/PgSQL.py", line 2660,
in __fetchOneRow
_r.getvalue(sel f._idx_, _i)))
File "/usr/lib/python2.2/site-packages/pyPgSQL/PgSQL.py", line 717,
in typecast
return PgNumeric(value , _p, _s)
File "/usr/lib/python2.2/site-packages/pyPgSQL/PgSQL.py", line 1335,
in __init__
raise OverflowError, "value too large for PgNumeric"
OverflowError: value too large for PgNumeric


So here's a specific string coming from the database for which the
PgNumeric class thinks it's too large. This smells like a bug to me.
The aforementioned table, customer, only has 1023 entries with the
following structure:

CREATE TABLE customer (ccustcode varchar(80), cgroupcode varchar(10),
clastname varchar(80), cfirstname varchar(80), cmi varchar(10),
ccompany varchar(80), caddress1 varchar(80), caddress2 varchar(80),
ccity varchar(80), cprovince varchar(80), czipcode varchar(10), iterms
integer, ycredit_limit numeric, npenalty_rate numeric,
default_routeco de varchar(10), lisdirector boolean);
Aha. Could you perhaps send me the contents of the table? I'm only
interested in the NUMERIC columns. Just omit the rest, as it's likely a
privacy issue otherwise.
PgSQL's fetchone() fortunately works though, as well as using
fetchall() on tables with few rows. Is there any alternative way of
using PyPgSQL that would not overflow in this situation?


It's a problem with the way PgNumeric thinks how large NUMERIC values
can become. pyPgSQL gets information from the backend in the
..description field of the cursor and infers the valid range of the
NUMERICs in the columns from this information. There must be a problem
with this.

Can you perhaps first try the CVS version of pyPgSQL?

It seems to me that the bug you've encountered is bug #697221, which is
already fixed in the CVS version:

http://sourceforge.net/tracker/index...28&atid=116528

If the problem persists with the CVS version, please send me more info,
like a dump of the NUMERIC columns.

If you want to contact me personally, please also CC
ge************* @gmx.de for the following days, as the DNS entries for my
mail server haven't catched up to my switching the server yet. [1]

-- Gerhard

[1] Damn (IDE) hard disks. This is the second HD crash on two different
servers within three months :-( But at least *this* time I have recent
backups ... Anybody got an idea about the failure rate of IDE hard
drives in medium-used servers? My ISP puts Excelstor HDs in the boxes
and claims they were the stablest ones in their tests.

Jul 18 '05 #2
Paolo Alexis Falcone wrote:
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:543 2:whitegold","d ondon","dondon" )
PgSQL.NoPos tgresCursor = 1
cur = db.cursor()
cur.execute ("SELECT * FROM customer")
data = cur.fetchall()

Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib/python2.2/site-packages/pyPgSQL/PgSQL.py", line 3106,
in fetchall
return self.__fetchMan yRows(self._row s_, _list)
File "/usr/lib/python2.2/site-packages/pyPgSQL/PgSQL.py", line 2684,
in __fetchManyRows
_j = self.__fetchOne Row()
File "/usr/lib/python2.2/site-packages/pyPgSQL/PgSQL.py", line 2660,
in __fetchOneRow
_r.getvalue(sel f._idx_, _i)))
File "/usr/lib/python2.2/site-packages/pyPgSQL/PgSQL.py", line 717,
in typecast
return PgNumeric(value , _p, _s)
File "/usr/lib/python2.2/site-packages/pyPgSQL/PgSQL.py", line 1335,
in __init__
raise OverflowError, "value too large for PgNumeric"
OverflowErro r: value too large for PgNumeric

The aforementioned table, customer, only has 1023 entries with the
following structure:

CREATE TABLE customer (ccustcode varchar(80), cgroupcode varchar(10),
clastname varchar(80), cfirstname varchar(80), cmi varchar(10),
ccompany varchar(80), caddress1 varchar(80), caddress2 varchar(80),
ccity varchar(80), cprovince varchar(80), czipcode varchar(10), iterms
integer, ycredit_limit numeric, npenalty_rate numeric,
default_routec ode varchar(10), lisdirector boolean);

PgSQL's fetchone() fortunately works though, as well as using
fetchall() on tables with few rows. Is there any alternative way of
using PyPgSQL that would not overflow in this situation?

Paolo,

The problem is not the number of rows, but the fact the conversion of a
PostgreSQL numeric to a PgNumeric is failing. This problem has been
fixed in the code in the CVS repository for the pyPgSQL project
<http://sourceforge.net/cvs/?group_id=16528 > on SourceForge. We will
also be releaseing a new version of pyPgSQL within the next couple of weeks.

--
_______________ _______________ _______________ _______________ _______________
____ | Billy G. Allie | Domain....: Bi********@mug. org
| /| | 7436 Hartwell | MSN.......: B_*******@email .msn.com
|-/-|----- | Dearborn, MI 48126|
|/ |LLIE | (313) 582-1540 |
Jul 18 '05 #3
Gerhard Häring <gh@ghaering.de > wrote in message news:<3E******* *******@ghaerin g.de>...
Can you perhaps first try the CVS version of pyPgSQL?

It seems to me that the bug you've encountered is bug #697221, which is
already fixed in the CVS version:


I've tried it and it already works like a charm :-)

Thanks!

-->paolo

Paolo Alexis Falcone
pf******@free.n et.ph
Jul 18 '05 #4

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

Similar topics

0
1441
by: Timo Virkkala | last post by:
Hello. I'm having some trouble with getting the pyPgSQL module to work. I installed it and the mxDateTime module into my local directory (I'm doing this on my university's server and I don't have access to /usr). When I try to import it I get the following error: >>> from pyPgSql import libpq Traceback (most recent call last): File...
2
3592
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...
2
1379
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...
2
1689
by: J Dubal | last post by:
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',database='rop') loccur = conn.cursor() loccur.execute("DECLARE itemcursor CURSOR FOR \ SELECT * FROM locmf")
3
2756
by: Gurpreet Sachdeva | last post by:
I am using Redhat 9.0/python2.3. I installed pyPgSQL-2.4.tar.gz and it was successfull. Now when I am trying to import that module, I got: Python 2.3.3 (#1, Jan 11 2005, 15:24:09) on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from pyPgSQL import PgSQL Traceback (most recent call last): File...
9
1718
by: Tin Gherdanarra | last post by:
Hallo, I'm trying to install pypgsql. However, I get syntax errors while compiling the C sources. The following excerpt from pgconnection.h looks a little funny to me: typedef struct { PyObject_HEAD /* Here is the syntax error, and rightly so */ PGconn *conn; PyObject *host;
1
372
by: Andrew | last post by:
Hello friends, I am building a website hosted through DSL box. It uses Form Authentication. When I tested from local network machine, it worked fine: Asking me to login if I tried non-public pages. After I typed in user name and password, it directed me to the page I wanted. However, if a person tried to access it through internet, e.g.,...
53
4176
by: Alan Silver | last post by:
Hello, I understand the issue that tables should be used for tabular data and not for layout, but I would like some clarification as to exactly what constitutes tabular data. For example, if I have a form, in which the user is required to fill in various bits of information, then laying out with a table makes it easy. A basic example...
0
1164
by: Eric | last post by:
Hey guys, Has anyone seen this error when installing trac? The problem seems related to pyPgSQL, which is installed. (Although I had to go in and add some headers to make it work) Templates directory > Creating and Initializing Project Failed to create environment.
0
7700
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
7614
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
7924
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. ...
1
7676
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
5513
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
5219
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
3642
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2114
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
1
1221
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.