From furri.josi at bluewin.ch Tue Jul 5 18:24:27 2005 From: furri.josi at bluewin.ch (Josef Furrer) Date: Tue, 5 Jul 2005 18:24:27 +0200 Subject: [DB-SIG] informixdb 1.4 Message-ID: <00e801c5817e$03d72160$1530a8c0@DCFX5P0J> Hello Carsten, I've downloaded your Python Database API informixdb 1.4. After that I installed it on a Unix Tru64. So far so got. The installation is completed and successfull. Now I try to use this API and I have a problem. When I define a cursor, this cursor works but when I try to fetch the cursor [fetchone()], it appears every time the same informix error: "informixdb.Error: Error -482 performing FETCH: Invalid operation on a non-SCROLL cursor" Next step: I changed in the file _informixdb.ec on line 1056 the declare section to: EXEC SQL DECLARE :cursorName SCROLL CURSOR FOR :queryName; The new installation work also, but when I use now my python script I have no more the problem -482, but I receive the error: Segmentation fault What is the Problem? Can You give me a Hint? Can You help me please? Thanks a lot. Regards, Josef -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/db-sig/attachments/20050705/42369f78/attachment.htm From phoebe at lambada.sanbi.ac.za Wed Jul 6 12:39:54 2005 From: phoebe at lambada.sanbi.ac.za (Phoebe Lesser) Date: Wed, 6 Jul 2005 12:39:54 +0200 (SAST) Subject: [DB-SIG] Testing Message-ID: <20050706123931.N19357@lambada.sanbi.ac.za> 123 im here bye bye From carsten at uniqsys.com Wed Jul 6 14:38:39 2005 From: carsten at uniqsys.com (Carsten Haese) Date: Wed, 06 Jul 2005 08:38:39 -0400 Subject: [DB-SIG] informixdb 1.4 In-Reply-To: <00e801c5817e$03d72160$1530a8c0@DCFX5P0J> References: <00e801c5817e$03d72160$1530a8c0@DCFX5P0J> Message-ID: <1120653519.22306.55.camel@dot.uniqsys.com> On Tue, 2005-07-05 at 12:24, Josef Furrer wrote: > Hello Carsten, > > I've downloaded your Python Database API informixdb 1.4. > After that I installed it on a Unix Tru64. > So far so got. The installation is completed and successfull. > Now I try to use this API and I have a problem. > When I define a cursor, this cursor works but when I try to fetch the > cursor [fetchone()], it appears every time the same informix error: > > "informixdb.Error: Error -482 performing FETCH: Invalid operation on a > non-SCROLL cursor" > > Next step: I changed in the file _informixdb.ec on line 1056 the > declare section to: > EXEC SQL DECLARE :cursorName SCROLL CURSOR FOR :queryName; > The new installation work also, but when I use now my python script I > have no more the problem -482, but I receive the error: > Segmentation fault > > What is the Problem? Can You give me a Hint? > Can You help me please? > > Thanks a lot. > > Regards, > Josef [I answered Josef off-list already, but since his cc finally appeared on the list, I'll respond on-list, too.] The problem is very mysterious since error number -482 should only occur if you attempt a FETCH PRIOR, FETCH FIRST, FETCH LAST, FETCH CURRENT, FETCH RELATIVE n, or FETCH ABSOLUTE n, and the informixdb code doesn't do any of that. In addition, when I try the unnecessary change to a scroll cursor on my Linux box, the change has no effect at all. Since I neither have nor know Tru64, I can only guess, and my best guess is that this problem is the result of using an Informix CSDK that's either outdated or incompatible with the OS version. If anybody on the list knows anything specific about Informix on Tru64, I'd like to hear their opinion about this. Best regards, -- Carsten Haese - Software Engineer | Phone: (419) 861-3331 Unique Systems, Inc. | FAX: (419) 861-3340 1446 Reynolds Rd, Suite 313 | Maumee, OH 43537 | mailto:carsten at uniqsys.com From gnumathetes at gmail.com Wed Jul 6 17:21:05 2005 From: gnumathetes at gmail.com (Don Parris) Date: Wed, 6 Jul 2005 11:21:05 -0400 Subject: [DB-SIG] MySQL Multi-Table Insert Strategy Message-ID: <6692614405070608214d152b6a@mail.gmail.com> Greetings, I'm new on the list, and just had a general question about the best approach for setting up a multi-table insert. I know that MySQL doesn't support this outright, but would most people recommend using a transaction? In my DB app, I have a table, person, that uses foreign keys from other tables (3-4). When I add someone to the person table, I want the data for their address to be inserted into the address table as well. Other data needs to be inserted into additional tables. I have a little experience with MySQL at a very basic level, and am new to programming & Python. I thought it would be best to ask this question here than on the Tutor list. Thanks, Don -- DC Parris GNU Evangelist http://matheteuo.org/ gnumathetes at gmail.com Free software is like God's love - you can share it with anyone anywhere anytime! From kolbe at kolbekegel.com Wed Jul 6 18:26:46 2005 From: kolbe at kolbekegel.com (Kolbe Kegel) Date: Wed, 6 Jul 2005 09:26:46 -0700 Subject: [DB-SIG] MySQL Multi-Table Insert Strategy In-Reply-To: <6692614405070608214d152b6a@mail.gmail.com> References: <6692614405070608214d152b6a@mail.gmail.com> Message-ID: Hi Don, > I'm new on the list, and just had a general question about the best > approach for setting up a multi-table insert. I know that MySQL > doesn't support this outright, but would most people recommend using a > transaction? This question is essentially neutral to the language-specific API that you're using. What you're describing is *exactly* when you should use a transaction. Bear in mind that all tables involved in the transaction will need to use the InnoDB storage engine if you want the transaction to make any sense (i.e. work as you hope). > In my DB app, I have a table, person, that uses foreign keys from > other tables (3-4). When I add someone to the person table, I want > the data for their address to be inserted into the address table as > well. Other data needs to be inserted into additional tables. BEGIN INSERT INTO people (...) VALUES (...) id = last_insert_id() INSERT INTO address (person_id, ...) VALUES (id, ...) INSERT INTO other (person_id, ...) VALUES (id, ...) COMMIT Check the return values of each of your statements and if anything is weird, ROLLBACK the transaction. Likewise, if the COMMIT fails or if you have to rollback, you should design your application so that it will retry the transaction in case the transaction could not be committed. This can happen because of deadlocks or other reasons, and a transaction-aware application should be able to deal with that. Regards, Kolbe From abingham at alumni.sfu.ca Wed Jul 6 20:29:55 2005 From: abingham at alumni.sfu.ca (Aaron Bingham) Date: Wed, 06 Jul 2005 20:29:55 +0200 Subject: [DB-SIG] MySQL Multi-Table Insert Strategy In-Reply-To: <6692614405070608214d152b6a@mail.gmail.com> (Don Parris's message of "Wed, 6 Jul 2005 11:21:05 -0400") References: <6692614405070608214d152b6a@mail.gmail.com> Message-ID: <87vf3ndbz0.fsf@nomad.bingham.de> Don Parris writes: > I'm new on the list, and just had a general question about the best > approach for setting up a multi-table insert. I know that MySQL > doesn't support this outright, but would most people recommend using a > transaction? This is precisely the kind of thing transactions are for. By all means use one. That way, if something goes wrong with the database or your program between updating, e.g., the person table and the address table, the database can't be left in a half-updated state. If you are not very familiar with databases and will be doing more work with them, I would recommend you find yourself a good product-independant book on the topic. I would recommend An Introduction to Database Systems by Chris Date (http://www.amazon.com/exec/obidos/tg/detail/-/0321197844/qid=1120674974/sr=8-1/ref=pd_bbs_ur_1/002-4259272-2816863?v=glance&s=books&n=507846). Regards, Aaron From randall at tnr.cc Tue Jul 12 05:59:55 2005 From: randall at tnr.cc (Randall Smith) Date: Mon, 11 Jul 2005 22:59:55 -0500 Subject: [DB-SIG] pypg pure Python db driver for Postgresql Message-ID: <42D3403B.60706@tnr.cc> I've been toying with the idea of pure Python database drivers such as Java jdbc type 4 drivers. I replaced the C portion of PyGreSQL to form a Python driver I'm calling pypg. You can download it from the location below. http://www.tnr.cc/pypg.html It's alpha so expect problems, but in my testing it works fine for normal operations. It speaks PG v3 protocol directly and it was easier to get working than I expected. I'm new to sockets and would really appreciate feedback on the networking portion of the code. Many will probably ask me why not just use the existing drivers? The same reasons pure Java drivers exist. They're ultra portable and eliminate dependencies. Ever used Oracle with Python? It sucks having to install those dependencies, especially on Linux. I use an application called Aqua Data Studio that ships with type 4 java drivers and that is very nice. I too would like to be able to include db drivers with an app. Another reason I'm doing it is because it is fun and educational. I look forward to constructive criticism. Randall From marcos at burke.ath.cx Tue Jul 12 09:16:29 2005 From: marcos at burke.ath.cx (Marcos =?ISO-8859-1?Q?S=E1nchez?= Provencio) Date: Tue, 12 Jul 2005 09:16:29 +0200 Subject: [DB-SIG] pypg pure Python db driver for Postgresql In-Reply-To: <42D3403B.60706@tnr.cc> References: <42D3403B.60706@tnr.cc> Message-ID: <1121152589.8804.2.camel@savin.proteus> Of course, there is an obvious question: How is performance? El lun, 11-07-2005 a las 22:59 -0500, Randall Smith escribi?: > I've been toying with the idea of pure Python database drivers such as > Java jdbc type 4 drivers. > > I replaced the C portion of PyGreSQL to form a Python driver I'm calling > pypg. You can download it from the location below. > > http://www.tnr.cc/pypg.html > > It's alpha so expect problems, but in my testing it works fine for > normal operations. > > It speaks PG v3 protocol directly and it was easier to get working than > I expected. I'm new to sockets and would really appreciate feedback on > the networking portion of the code. > > Many will probably ask me why not just use the existing drivers? The > same reasons pure Java drivers exist. They're ultra portable and > eliminate dependencies. Ever used Oracle with Python? It sucks having > to install those dependencies, especially on Linux. I use an > application called Aqua Data Studio that ships with type 4 java drivers > and that is very nice. I too would like to be able to include db > drivers with an app. Another reason I'm doing it is because it is fun > and educational. > > I look forward to constructive criticism. > > Randall > > > _______________________________________________ > DB-SIG maillist - DB-SIG at python.org > http://mail.python.org/mailman/listinfo/db-sig -- Marcos S?nchez Provencio From bortzmeyer at nic.fr Tue Jul 12 10:52:53 2005 From: bortzmeyer at nic.fr (Stephane Bortzmeyer) Date: Tue, 12 Jul 2005 10:52:53 +0200 Subject: [DB-SIG] pypg pure Python db driver for Postgresql In-Reply-To: <42D3403B.60706@tnr.cc> References: <42D3403B.60706@tnr.cc> Message-ID: <20050712085253.GA29176@nic.fr> On Mon, Jul 11, 2005 at 10:59:55PM -0500, Randall Smith wrote a message of 32 lines which said: > I replaced the C portion of PyGreSQL to form a Python driver I'm > calling pypg. You can download it from the location below. I was planning to test its performance, using the test we developed to compare psycopg and PoPy, but it always fail (do note that I was trying to use the local connection, "host" is empty, but if I specify "host=localhost", I get the same error): Traceback (most recent call last): File "test.py", line 110, in ? connection = db_module.connect("dbname=db-comp-registry") File "/usr/local/lib/python2.3/site-packages/pypg/pgdb2.py", line 413, in connect dbtty, dbuser, dbpasswd) File "/usr/local/lib/python2.3/site-packages/pypg/_mypg.py", line 175, in connect return Connection(dbhost, dbport, dbbase, dbuser, dbpasswd) File "/usr/local/lib/python2.3/site-packages/pypg/_mypg.py", line 58, in __init__ self.connect() File "/usr/local/lib/python2.3/site-packages/pypg/_mypg.py", line 62, in connect sock.connect((self.host, self.port)) File "", line 1, in connect socket.gaierror: (-2, 'Name or service not known') From randall at tnr.cc Tue Jul 12 13:41:14 2005 From: randall at tnr.cc (Randall Smith) Date: Tue, 12 Jul 2005 06:41:14 -0500 Subject: [DB-SIG] pypg pure Python db driver for Postgresql In-Reply-To: <20050712085253.GA29176@nic.fr> References: <42D3403B.60706@tnr.cc> <20050712085253.GA29176@nic.fr> Message-ID: <42D3AC5A.7020708@tnr.cc> That's a name resolution error. Make sure localhost is defined in your /etc/hosts (or equivalent) file and also try 127.0.0.1. Randall Stephane Bortzmeyer wrote: > On Mon, Jul 11, 2005 at 10:59:55PM -0500, > Randall Smith wrote > a message of 32 lines which said: > > >>I replaced the C portion of PyGreSQL to form a Python driver I'm >>calling pypg. You can download it from the location below. > > > I was planning to test its performance, using the test we developed to > compare psycopg and PoPy, but it always fail (do note that I was > trying to use the local connection, "host" is empty, but if I specify > "host=localhost", I get the same error): > > Traceback (most recent call last): > File "test.py", line 110, in ? > connection = db_module.connect("dbname=db-comp-registry") > File "/usr/local/lib/python2.3/site-packages/pypg/pgdb2.py", line 413, in connect > dbtty, dbuser, dbpasswd) > File "/usr/local/lib/python2.3/site-packages/pypg/_mypg.py", line 175, in connect > return Connection(dbhost, dbport, dbbase, dbuser, dbpasswd) > File "/usr/local/lib/python2.3/site-packages/pypg/_mypg.py", line 58, in __init__ > self.connect() > File "/usr/local/lib/python2.3/site-packages/pypg/_mypg.py", line 62, in connect > sock.connect((self.host, self.port)) > File "", line 1, in connect > socket.gaierror: (-2, 'Name or service not known') From bortzmeyer at nic.fr Tue Jul 12 13:54:25 2005 From: bortzmeyer at nic.fr (Stephane Bortzmeyer) Date: Tue, 12 Jul 2005 13:54:25 +0200 Subject: [DB-SIG] pypg pure Python db driver for Postgresql In-Reply-To: <42D3AC5A.7020708@tnr.cc> References: <42D3403B.60706@tnr.cc> <20050712085253.GA29176@nic.fr> <42D3AC5A.7020708@tnr.cc> Message-ID: <20050712115425.GA10735@nic.fr> On Tue, Jul 12, 2005 at 06:41:14AM -0500, Randall Smith wrote a message of 33 lines which said: > That's a name resolution error. I know :-) > Make sure localhost is defined in your /etc/hosts Remember that it fails even if the DSN is just "dbname=something". And of course localhost exists: ~ % ping localhost PING localhost (127.0.0.1) 56(84) bytes of data. 64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.022 ms From marcos at burke.ath.cx Tue Jul 12 14:19:27 2005 From: marcos at burke.ath.cx (Marcos =?ISO-8859-1?Q?S=E1nchez?= Provencio) Date: Tue, 12 Jul 2005 14:19:27 +0200 Subject: [DB-SIG] pypg pure Python db driver for Postgresql In-Reply-To: <20050712085253.GA29176@nic.fr> References: <42D3403B.60706@tnr.cc> <20050712085253.GA29176@nic.fr> Message-ID: <1121170767.8804.9.camel@savin.proteus> Usually, in PostgreSQL, no host means Unix socket, not localhost. Some clients can not handle unix sockets. El mar, 12-07-2005 a las 10:52 +0200, Stephane Bortzmeyer escribi?: > On Mon, Jul 11, 2005 at 10:59:55PM -0500, > Randall Smith wrote > a message of 32 lines which said: > > > I replaced the C portion of PyGreSQL to form a Python driver I'm > > calling pypg. You can download it from the location below. > > I was planning to test its performance, using the test we developed to > compare psycopg and PoPy, but it always fail (do note that I was > trying to use the local connection, "host" is empty, but if I specify > "host=localhost", I get the same error): > > Traceback (most recent call last): > File "test.py", line 110, in ? > connection = db_module.connect("dbname=db-comp-registry") > File "/usr/local/lib/python2.3/site-packages/pypg/pgdb2.py", line 413, in connect > dbtty, dbuser, dbpasswd) > File "/usr/local/lib/python2.3/site-packages/pypg/_mypg.py", line 175, in connect > return Connection(dbhost, dbport, dbbase, dbuser, dbpasswd) > File "/usr/local/lib/python2.3/site-packages/pypg/_mypg.py", line 58, in __init__ > self.connect() > File "/usr/local/lib/python2.3/site-packages/pypg/_mypg.py", line 62, in connect > sock.connect((self.host, self.port)) > File "", line 1, in connect > socket.gaierror: (-2, 'Name or service not known') > _______________________________________________ > DB-SIG maillist - DB-SIG at python.org > http://mail.python.org/mailman/listinfo/db-sig -- Marcos S?nchez Provencio From bortzmeyer at nic.fr Tue Jul 12 14:30:14 2005 From: bortzmeyer at nic.fr (Stephane Bortzmeyer) Date: Tue, 12 Jul 2005 14:30:14 +0200 Subject: [DB-SIG] pypg pure Python db driver for Postgresql In-Reply-To: <1121170767.8804.9.camel@savin.proteus> References: <42D3403B.60706@tnr.cc> <20050712085253.GA29176@nic.fr> <1121170767.8804.9.camel@savin.proteus> Message-ID: <20050712123014.GA15204@nic.fr> On Tue, Jul 12, 2005 at 02:19:27PM +0200, Marcos S?nchez Provencio wrote a message of 6 lines which said: > Usually, in PostgreSQL, no host means Unix socket, not > localhost. Someclients can not handle unix sockets. This would be a sufficient reason for dropping pypg. But, anyway, as I already wrote, the same problem and the same error message occur wether I use "dbname=something" or "host=localhost, dbname=something". From randall at tnr.cc Tue Jul 12 14:39:36 2005 From: randall at tnr.cc (Randall Smith) Date: Tue, 12 Jul 2005 07:39:36 -0500 Subject: [DB-SIG] pypg pure Python db driver for Postgresql In-Reply-To: <20050712085253.GA29176@nic.fr> References: <42D3403B.60706@tnr.cc> <20050712085253.GA29176@nic.fr> Message-ID: <42D3BA08.4080700@tnr.cc> Ah, Try to use keyword arguments instead of a connection string. I was able to reproduce the error by using a connection string. Sorry. Randall Stephane Bortzmeyer wrote: > On Mon, Jul 11, 2005 at 10:59:55PM -0500, > Randall Smith wrote > a message of 32 lines which said: > > >>I replaced the C portion of PyGreSQL to form a Python driver I'm >>calling pypg. You can download it from the location below. > > > I was planning to test its performance, using the test we developed to > compare psycopg and PoPy, but it always fail (do note that I was > trying to use the local connection, "host" is empty, but if I specify > "host=localhost", I get the same error): > > Traceback (most recent call last): > File "test.py", line 110, in ? > connection = db_module.connect("dbname=db-comp-registry") > File "/usr/local/lib/python2.3/site-packages/pypg/pgdb2.py", line 413, in connect > dbtty, dbuser, dbpasswd) > File "/usr/local/lib/python2.3/site-packages/pypg/_mypg.py", line 175, in connect > return Connection(dbhost, dbport, dbbase, dbuser, dbpasswd) > File "/usr/local/lib/python2.3/site-packages/pypg/_mypg.py", line 58, in __init__ > self.connect() > File "/usr/local/lib/python2.3/site-packages/pypg/_mypg.py", line 62, in connect > sock.connect((self.host, self.port)) > File "", line 1, in connect > socket.gaierror: (-2, 'Name or service not known') From marcos at burke.ath.cx Tue Jul 12 14:46:49 2005 From: marcos at burke.ath.cx (Marcos =?ISO-8859-1?Q?S=E1nchez?= Provencio) Date: Tue, 12 Jul 2005 14:46:49 +0200 Subject: [DB-SIG] pypg pure Python db driver for Postgresql In-Reply-To: <20050712123014.GA15204@nic.fr> References: <42D3403B.60706@tnr.cc> <20050712085253.GA29176@nic.fr> <1121170767.8804.9.camel@savin.proteus> <20050712123014.GA15204@nic.fr> Message-ID: <1121172409.8804.12.camel@savin.proteus> Does psql work with 'localhost'? It might be that inet sockets are not enabled. I don't think this would be a reason to drop it, may be to improve it ;-) El mar, 12-07-2005 a las 14:30 +0200, Stephane Bortzmeyer escribi?: > On Tue, Jul 12, 2005 at 02:19:27PM +0200, > Marcos S?nchez Provencio wrote > a message of 6 lines which said: > > > Usually, in PostgreSQL, no host means Unix socket, not > > localhost. Someclients can not handle unix sockets. > > This would be a sufficient reason for dropping pypg. But, anyway, as I > already wrote, the same problem and the same error message occur > wether I use "dbname=something" or "host=localhost, dbname=something". -- Marcos S?nchez Provencio From randall at tnr.cc Tue Jul 12 14:57:16 2005 From: randall at tnr.cc (Randall Smith) Date: Tue, 12 Jul 2005 07:57:16 -0500 Subject: [DB-SIG] pypg pure Python db driver for Postgresql In-Reply-To: <20050712123014.GA15204@nic.fr> References: <42D3403B.60706@tnr.cc> <20050712085253.GA29176@nic.fr> <1121170767.8804.9.camel@savin.proteus> <20050712123014.GA15204@nic.fr> Message-ID: <42D3BE2C.6010903@tnr.cc> In its current state (early alpha), pypg does not support Unix sockets or connection strings. Not that it can't. Just that I didn't code or test these features yet. You may connect like so: import pypg con = pypg.connect(host='localhost', database='mydb', user='uname', password='mypass') # do stuff con.close() Also note that as a requirement of PyGreSQL, you need mxdatetime. I'll probably change that to the standard library datetime module. Thanks for trying it out and I appreciate your feedback. Randall Stephane Bortzmeyer wrote: > On Tue, Jul 12, 2005 at 02:19:27PM +0200, > Marcos S?nchez Provencio wrote > a message of 6 lines which said: > > >>Usually, in PostgreSQL, no host means Unix socket, not >>localhost. Someclients can not handle unix sockets. > > > This would be a sufficient reason for dropping pypg. But, anyway, as I > already wrote, the same problem and the same error message occur > wether I use "dbname=something" or "host=localhost, dbname=something". > _______________________________________________ > DB-SIG maillist - DB-SIG at python.org > http://mail.python.org/mailman/listinfo/db-sig From randall at tnr.cc Tue Jul 12 15:15:27 2005 From: randall at tnr.cc (Randall Smith) Date: Tue, 12 Jul 2005 08:15:27 -0500 Subject: [DB-SIG] pypg pure Python db driver for Postgresql In-Reply-To: <42D36647.6090502@nekhem.com> References: <42D3403B.60706@tnr.cc> <42D36647.6090502@nekhem.com> Message-ID: <42D3C26F.4070506@tnr.cc> I see you are working with the PyGreSQL group and seem to have much more experience than I do in database driver development so maybe I should be helping you. I'm interested in working with you on a pure Python driver. The majority of the work I've done is on learning and implementing the PG protocol. I have not done much in the area of sockets, but it sounds like you have. Is there an existing project where this could be applied or does it warrant its own project? I have a few sourceforge projects going and could start up a new one for this. Randall Thierry MICHEL wrote: > Hi Randall, > > I'm the developer of the python postgresql db driver Popy and I'm also > working on a pure python driver for postgresql. > I'm very interested in working w/ you on this driver (may be creating a > serious project somewhere). > I worked on some ideas about worker agents for dealing with connections > (and sockets) so if I could help you let me know. > > Regards > > > Randall Smith wrote: > >> I've been toying with the idea of pure Python database drivers such as >> Java jdbc type 4 drivers. >> >> I replaced the C portion of PyGreSQL to form a Python driver I'm >> calling pypg. You can download it from the location below. >> >> http://www.tnr.cc/pypg.html >> >> It's alpha so expect problems, but in my testing it works fine for >> normal operations. >> >> It speaks PG v3 protocol directly and it was easier to get working >> than I expected. I'm new to sockets and would really appreciate >> feedback on the networking portion of the code. >> >> Many will probably ask me why not just use the existing drivers? The >> same reasons pure Java drivers exist. They're ultra portable and >> eliminate dependencies. Ever used Oracle with Python? It sucks >> having to install those dependencies, especially on Linux. I use an >> application called Aqua Data Studio that ships with type 4 java >> drivers and that is very nice. I too would like to be able to include >> db drivers with an app. Another reason I'm doing it is because it is >> fun and educational. >> >> I look forward to constructive criticism. >> >> Randall >> >> >> _______________________________________________ >> DB-SIG maillist - DB-SIG at python.org >> http://mail.python.org/mailman/listinfo/db-sig >> >> > From randall at tnr.cc Tue Jul 12 15:38:53 2005 From: randall at tnr.cc (Randall Smith) Date: Tue, 12 Jul 2005 08:38:53 -0500 Subject: [DB-SIG] pypg pure Python db driver for Postgresql In-Reply-To: <20050712130923.GA17453@nic.fr> References: <42D3403B.60706@tnr.cc> <20050712085253.GA29176@nic.fr> <1121170767.8804.9.camel@savin.proteus> <20050712123014.GA15204@nic.fr> <42D3BE01.4000708@tnr.cc> <20050712130923.GA17453@nic.fr> Message-ID: <42D3C7ED.1040705@tnr.cc> Well, you found two bugs. A bug in the protocol (lack of handling) and a bug in the error handler. I uploaded a new version to fix the bug in the error handler, but I don't know what message it is that is not being handled. emsg = 'Did not handle response, %s' % nextmsg_format_name should read emsg = 'Did not handle response, %s' % nextmsg.format_name This happens after an authentication attempt if neither an 'ErrorResponse' or 'AuthenticationOk' message is received. From the docs: The authentication cycle ends with the server either rejecting the connection attempt (ErrorResponse), or sending AuthenticationOk. Maybe I have not supported your authentication scheme yet. What authentication scheme are you using? For that matter what is your OS, Postgresql version etc. Randall Stephane Bortzmeyer wrote: > On Tue, Jul 12, 2005 at 07:56:33AM -0500, > Randall Smith wrote > a message of 35 lines which said: > > >>In its current state (early alpha), pypg does not support Unix >>sockets or connection strings. > > > :-( > > >>You may connect like so: > > > New error message :-) > > % python test.py > Traceback (most recent call last): > File "test.py", line 115, in ? > user='bortzmeyer') > File "/usr/local/lib/python2.3/site-packages/pypg/pgdb2.py", line 413, in connect > dbtty, dbuser, dbpasswd) > File "/usr/local/lib/python2.3/site-packages/pypg/_mypg.py", line 175, in connect > return Connection(dbhost, dbport, dbbase, dbuser, dbpasswd) > File "/usr/local/lib/python2.3/site-packages/pypg/_mypg.py", line 58, in __init__ > self.connect() > File "/usr/local/lib/python2.3/site-packages/pypg/_mypg.py", line 84, in connect > emsg = 'Did not handle response, %s' % nextmsg_format_name > NameError: global name 'nextmsg_format_name' is not defined From bortzmeyer at nic.fr Tue Jul 12 15:57:57 2005 From: bortzmeyer at nic.fr (Stephane Bortzmeyer) Date: Tue, 12 Jul 2005 15:57:57 +0200 Subject: [DB-SIG] pypg pure Python db driver for Postgresql In-Reply-To: <42D3C7ED.1040705@tnr.cc> References: <42D3403B.60706@tnr.cc> <20050712085253.GA29176@nic.fr> <1121170767.8804.9.camel@savin.proteus> <20050712123014.GA15204@nic.fr> <42D3BE01.4000708@tnr.cc> <20050712130923.GA17453@nic.fr> <42D3C7ED.1040705@tnr.cc> Message-ID: <20050712135757.GA21750@nic.fr> On Tue, Jul 12, 2005 at 08:38:53AM -0500, Randall Smith wrote a message of 56 lines which said: > should read > > emsg = 'Did not handle response, %s' % nextmsg.format_name Now, I have: Exception: Did not handle response, ParameterStatus > Maybe I have not supported your authentication scheme yet. What > authentication scheme are you using? # All IPv4 connections from localhost host all all 127.0.0.1 255.255.255.255 ident sameuser > For that matter what is your OS, Debian GNU/Linux 3.1 "sarge". > Postgresql version etc. PostgreSQL 7.4.7 Python 2.3.5 From randall at tnr.cc Tue Jul 12 16:56:49 2005 From: randall at tnr.cc (Randall Smith) Date: Tue, 12 Jul 2005 09:56:49 -0500 Subject: [DB-SIG] pypg pure Python db driver for Postgresql In-Reply-To: <20050712135757.GA21750@nic.fr> References: <42D3403B.60706@tnr.cc> <20050712085253.GA29176@nic.fr> <1121170767.8804.9.camel@savin.proteus> <20050712123014.GA15204@nic.fr> <42D3BE01.4000708@tnr.cc> <20050712130923.GA17453@nic.fr> <42D3C7ED.1040705@tnr.cc> <20050712135757.GA21750@nic.fr> Message-ID: <42D3DA31.4090303@tnr.cc> You must think I'm playing some cruel trick on you. I promise I'm not. I tested this on Ubuntu, OS X 10.3, and Windows 2000 with Python 2.3/2.4 and PG 7.4. The thing that baffles me about your error is that it appears that you got authenticated without receiving an AuthenticationOk response. On top of that I don't know how you authenticated using IDENT because my attempts to do so failed. You might try md5 authentication host all all 127.0.0.1 255.255.255.255 ident sameuser host all all 127.0.0.1 255.255.255.255 md5 Sorry for the headaches. If you figure out what the problem is, I would like to know. Thanks. Randall Stephane Bortzmeyer wrote: > On Tue, Jul 12, 2005 at 08:38:53AM -0500, > Randall Smith wrote > a message of 56 lines which said: > > >>should read >> >>emsg = 'Did not handle response, %s' % nextmsg.format_name > > > Now, I have: > > Exception: Did not handle response, ParameterStatus > > >>Maybe I have not supported your authentication scheme yet. What >>authentication scheme are you using? > > > # All IPv4 connections from localhost > host all all 127.0.0.1 255.255.255.255 ident sameuser > > >>For that matter what is your OS, > > > Debian GNU/Linux 3.1 "sarge". > > >>Postgresql version etc. > > > PostgreSQL 7.4.7 > Python 2.3.5 From bortzmeyer at nic.fr Tue Jul 12 17:19:25 2005 From: bortzmeyer at nic.fr (Stephane Bortzmeyer) Date: Tue, 12 Jul 2005 17:19:25 +0200 Subject: [DB-SIG] pypg pure Python db driver for Postgresql In-Reply-To: <42D3DA31.4090303@tnr.cc> References: <42D3403B.60706@tnr.cc> <20050712085253.GA29176@nic.fr> <1121170767.8804.9.camel@savin.proteus> <20050712123014.GA15204@nic.fr> <42D3BE01.4000708@tnr.cc> <20050712130923.GA17453@nic.fr> <42D3C7ED.1040705@tnr.cc> <20050712135757.GA21750@nic.fr> <42D3DA31.4090303@tnr.cc> Message-ID: <20050712151925.GA31404@nic.fr> On Tue, Jul 12, 2005 at 09:56:49AM -0500, Randall Smith wrote a message of 56 lines which said: > On top of that I don't know how you authenticated using IDENT > because my attempts to do so failed. With 'host = localhost' (but I insist that Unix socket support is necessary to me), you need an ident server (not with Unix sockets which uses the PEERCREED option of the socket). May be you did not have one? % telnet localhost ident Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. ... % psql -h localhost registry Welcome to psql 7.4.7, the PostgreSQL interactive terminal. ... registry=> % tail /var/log/daemon.log ... Jul 12 17:15:12 batilda identd[30936]: started From randall at tnr.cc Tue Jul 12 17:40:08 2005 From: randall at tnr.cc (Randall Smith) Date: Tue, 12 Jul 2005 10:40:08 -0500 Subject: [DB-SIG] pypg pure Python db driver for Postgresql In-Reply-To: <20050712151925.GA31404@nic.fr> References: <42D3403B.60706@tnr.cc> <20050712085253.GA29176@nic.fr> <1121170767.8804.9.camel@savin.proteus> <20050712123014.GA15204@nic.fr> <42D3BE01.4000708@tnr.cc> <20050712130923.GA17453@nic.fr> <42D3C7ED.1040705@tnr.cc> <20050712135757.GA21750@nic.fr> <42D3DA31.4090303@tnr.cc> <20050712151925.GA31404@nic.fr> Message-ID: <42D3E458.6020208@tnr.cc> That's it. tail /var/log/daemon.log Jul 12 10:23:32 localhost identd[568]: started Jul 12 10:23:32 localhost identd[568]: netlink_lookup: write failed: Connection refused So what probably happened is that there is no 'AuthenticationOk' message returned for ident. That's why you got the immediate 'ParameterStatus' message. For now, I know that md5, cleartext, and trust work. I have updated pypg to work with ident authentication and put the new version on the website http://www.tnr.cc/pypg.html. I'll add support for Unix sockets later. Thanks. You've been helpful. Randall Stephane Bortzmeyer wrote: > On Tue, Jul 12, 2005 at 09:56:49AM -0500, > Randall Smith wrote > a message of 56 lines which said: > > >>On top of that I don't know how you authenticated using IDENT >>because my attempts to do so failed. > > > With 'host = localhost' (but I insist that Unix socket support is > necessary to me), you need an ident server (not with Unix sockets > which uses the PEERCREED option of the socket). May be you did not > have one? > > % telnet localhost ident > Trying 127.0.0.1... > Connected to localhost. > Escape character is '^]'. > ... > > % psql -h localhost registry > Welcome to psql 7.4.7, the PostgreSQL interactive terminal. > ... > registry=> > > % tail /var/log/daemon.log > ... > Jul 12 17:15:12 batilda identd[30936]: started From bortzmeyer at nic.fr Wed Jul 13 16:04:41 2005 From: bortzmeyer at nic.fr (Stephane Bortzmeyer) Date: Wed, 13 Jul 2005 16:04:41 +0200 Subject: [DB-SIG] pypg pure Python db driver for Postgresql In-Reply-To: <42D49B87.3070200@tnr.cc> References: <20050712085253.GA29176@nic.fr> <1121170767.8804.9.camel@savin.proteus> <20050712123014.GA15204@nic.fr> <42D3BE01.4000708@tnr.cc> <20050712130923.GA17453@nic.fr> <42D3C7ED.1040705@tnr.cc> <20050712135757.GA21750@nic.fr> <42D3DA31.4090303@tnr.cc> <20050712151925.GA31404@nic.fr> <42D49B87.3070200@tnr.cc> Message-ID: <20050713140441.GA32081@nic.fr> On Tue, Jul 12, 2005 at 11:41:43PM -0500, Randall Smith wrote a message of 52 lines which said: > I put in ident support and Unix socket support as well as taking the > username from the process when it is not specified. OK, it works much better now. Performance tests can be done and they seem to show that pypg is slower but you may decide by yourself if it is *too* slow: % python test.py Result with 100 repetitions: INSERT: 0.4 msec/pass SELECT (with join): 0.6 msec/pass DELETE: 0.3 msec/pass % python test.py Result with 100 repetitions: INSERT: 0.7 msec/pass SELECT (with join): 1.1 msec/pass DELETE: 0.6 msec/pass From randall at tnr.cc Wed Jul 13 16:21:59 2005 From: randall at tnr.cc (Randall Smith) Date: Wed, 13 Jul 2005 09:21:59 -0500 Subject: [DB-SIG] pypg pure Python db driver for Postgresql In-Reply-To: <20050713140441.GA32081@nic.fr> References: <20050712085253.GA29176@nic.fr> <1121170767.8804.9.camel@savin.proteus> <20050712123014.GA15204@nic.fr> <42D3BE01.4000708@tnr.cc> <20050712130923.GA17453@nic.fr> <42D3C7ED.1040705@tnr.cc> <20050712135757.GA21750@nic.fr> <42D3DA31.4090303@tnr.cc> <20050712151925.GA31404@nic.fr> <42D49B87.3070200@tnr.cc> <20050713140441.GA32081@nic.fr> Message-ID: <42D52387.5070104@tnr.cc> I haven't done any speed optimization or even profiled the code, so that looks really good to me. I think optimization might help with parameter binding and type conversion. Did your tests include parameters? Could you run your tests against PyGreSQL from which pypg is derived? That would show a clearer picutre of the speed difference between C/Python for this application. Randall Stephane Bortzmeyer wrote: > On Tue, Jul 12, 2005 at 11:41:43PM -0500, > Randall Smith wrote > a message of 52 lines which said: > > >>I put in ident support and Unix socket support as well as taking the >>username from the process when it is not specified. > > > OK, it works much better now. > > Performance tests can be done and they seem to show that pypg is > slower but you may decide by yourself if it is *too* slow: > > % python test.py > Result with > 100 repetitions: > INSERT: 0.4 msec/pass > SELECT (with join): 0.6 msec/pass > DELETE: 0.3 msec/pass > > % python test.py > Result with > 100 repetitions: > INSERT: 0.7 msec/pass > SELECT (with join): 1.1 msec/pass > DELETE: 0.6 msec/pass From lalvarez at novamens.com Wed Jul 13 21:34:55 2005 From: lalvarez at novamens.com (Lucas Alvarez) Date: Wed, 13 Jul 2005 16:34:55 -0300 Subject: [DB-SIG] Reference Message-ID: Hi, I want access to oracle databases and I don?t know which modules I have to use. Does someone have references from "cx_Oracle". Thanks in advance. Lucas Alvarez -- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/ From marcos at burke.ath.cx Wed Jul 13 21:46:21 2005 From: marcos at burke.ath.cx (Marcos =?ISO-8859-1?Q?S=E1nchez?= Provencio) Date: Wed, 13 Jul 2005 21:46:21 +0200 Subject: [DB-SIG] Reference In-Reply-To: References: Message-ID: <1121283981.5968.2.camel@localhost.localdomain> I have used cx_oracle in real life. It works fine. There is an active cx_oracle list which you can use should you find any trouble. El mi?, 13-07-2005 a las 16:34 -0300, Lucas Alvarez escribi?: > Hi, I want access to oracle databases and I don?t know which modules I > have to use. Does someone have references from "cx_Oracle". > Thanks in advance. > > > > Lucas Alvarez > > > > From fog at initd.org Wed Jul 13 23:43:55 2005 From: fog at initd.org (Federico Di Gregorio) Date: Wed, 13 Jul 2005 23:43:55 +0200 Subject: [DB-SIG] pypg pure Python db driver for Postgresql In-Reply-To: <42D52387.5070104@tnr.cc> References: <20050712085253.GA29176@nic.fr> <1121170767.8804.9.camel@savin.proteus> <20050712123014.GA15204@nic.fr> <42D3BE01.4000708@tnr.cc> <20050712130923.GA17453@nic.fr> <42D3C7ED.1040705@tnr.cc> <20050712135757.GA21750@nic.fr> <42D3DA31.4090303@tnr.cc> <20050712151925.GA31404@nic.fr> <42D49B87.3070200@tnr.cc> <20050713140441.GA32081@nic.fr> <42D52387.5070104@tnr.cc> Message-ID: <1121291035.18423.1.camel@iris> Il giorno mer, 13/07/2005 alle 09.21 -0500, Randall Smith ha scritto: > I haven't done any speed optimization or even profiled the code, so that > looks really good to me. I think optimization might help with parameter > binding and type conversion. > > Did your tests include parameters? It is very important to test with lots of bound parameters. For example psycopg spends a lot of time trying to convert data to and from the right types. federico From randall at tnr.cc Thu Jul 14 17:34:39 2005 From: randall at tnr.cc (Randall Smith) Date: Thu, 14 Jul 2005 10:34:39 -0500 Subject: [DB-SIG] jdbc proxy + python driver Message-ID: <42D6860F.20101@tnr.cc> Since I ran across type 4 JDBC drivers, I've liked the idea of their portability and lack of dependencies. I even started work on one for Python and am so far pleased with it. But what about databases for which a pure Python driver can't be built? Say Oracle, who's protocol is proprietary and undocumented (I can't find any documentation.). Unless Oracle makes the protocol public or some protocol guru reverse engineers it (which I think is against their license agreement), we'll never have one. It's been suggested to use the JDBC drivers from Jython or Jython + XMLRPC to use in CPython. I've never liked that idea much. What about using a Java JDBC Proxy + Python Driver for the API. Something like SQL Relay, but more simple and written in Java. It would use the type 4 JDBC drivers and expose an API. Then a Python driver would exist to use the service. What I like about this is that the only non-Python dependencies are a JVM and the proxy server. Many systems already have a JVM installed. They entire process including the proxy startup and shutdown could be controlled from inside of the Python application making it easy to package. Does this exist? I did some googling, but didn't turn up anything close enough. Randall From s_david_rose at hotmail.com Mon Jul 25 16:30:15 2005 From: s_david_rose at hotmail.com (GMane Python) Date: Mon, 25 Jul 2005 10:30:15 -0400 Subject: [DB-SIG] MySQLdb -- BLOB is array Message-ID: Hello all. I'm new to python, and to Mysql, too. I'm trying stuff out, and wanted to take a photo in a program and insert it into a MySQL table as a BLOB. When trying to retrieve it, I get an array('c', ). I do a result = cursor.fetchall(), but how can I get the from the result array? Thank you! Dave From andy47 at halfcooked.com Tue Jul 26 14:33:08 2005 From: andy47 at halfcooked.com (Andy Todd) Date: Tue, 26 Jul 2005 22:33:08 +1000 Subject: [DB-SIG] MySQLdb -- BLOB is array In-Reply-To: References: Message-ID: <42E62D84.8000608@halfcooked.com> GMane Python wrote: > Hello all. > I'm new to python, and to Mysql, too. I'm trying stuff out, and wanted to > take a photo in a program and insert it into a MySQL table as a BLOB. When > trying to retrieve it, I get an array('c', ). > > I do a result = cursor.fetchall(), but how can I get the instance> from the result array? > > Thank you! > Dave > Dave, It's probably easier if you provide some sample code to illustrate your problem and any error messages you observe when you try and run it. From the brief description you've given it seems that you may need to read the tutorial on sequences and lists [1] because this is what is returned from a 'fetchall' method. Take a look at the DB-API 2.0 documentation [2] for information about this. It looks like the MySQLdb module is managing to figure out that you've stored a photo in the database and returned it as an appropriate object. Have you got the Python Imaging Library [3] installed? Because that's what you need to work with your photo. [1] http://docs.python.org/tut/node7.html#SECTION007300000000000000000 [2] http://www.python.org/peps/pep-0249.html [3] http://www.pythonware.com/products/pil/ Regards, Andy -- -------------------------------------------------------------------------------- From the desk of Andrew J Todd esq - http://www.halfcooked.com/ From farcepest at gmail.com Tue Jul 26 15:23:42 2005 From: farcepest at gmail.com (Andy Dustman) Date: Tue, 26 Jul 2005 09:23:42 -0400 Subject: [DB-SIG] MySQLdb -- BLOB is array In-Reply-To: References: Message-ID: <9826f3800507260623459d89f7@mail.gmail.com> On 7/25/05, GMane Python wrote: > Hello all. > I'm new to python, and to Mysql, too. I'm trying stuff out, and wanted to > take a photo in a program and insert it into a MySQL table as a BLOB. When > trying to retrieve it, I get an array('c', ). > > I do a result = cursor.fetchall(), but how can I get the instance> from the result array? You should read the Python library documentation for the array module, or type in the interpreter: >>> help('array') You may find the tostring() method to be useful. -- Computer interfaces should never be made of meat. http://www.terrybisson.com/meat.html From gnumathetes at gmail.com Thu Jul 28 02:35:10 2005 From: gnumathetes at gmail.com (Don Parris) Date: Wed, 27 Jul 2005 20:35:10 -0400 Subject: [DB-SIG] PyGreSQL (pgdb) Problem Message-ID: <669261440507271735259be809@mail.gmail.com> Greetings, I'm running SUSE Linux 9.2, Python 2.3.4. I'm new to Python/programming. I basically installed most of the DVD when I installed SUSE last Fall. Things *should* be working properly, but... What originally started as a MySQL project is now using Postgres for the larger feature set. Instead of importing MySQLdb, I now use the PyGreSQL pgdb module. When attempting to load the pgdb module for use in my script, I get this traceback (same when I try it at the command-line): >>> pgdb.connect('localhost:chaddb_a_test:donp:d1o1l2l4') Traceback (most recent call last): File "", line 1, in ? NameError: name 'pgdb' is not defined >>> import pgdb Traceback (most recent call last): File "", line 1, in ? File "/usr/lib/python2.3/site-packages/pgdb.py", line 65, in ? except ImportError: import DateTime ImportError: No module named DateTime In the pgdb module, I found this (which matches with the traceback): # Marc-Andre is changing where DateTime goes. This handles it either way. try: from mx import DateTime except ImportError: import DateTime I have spent a fair amount of time searching the archives for this issue, but have thus far turned up nothing useful. I have no module "mx" that I can find in ../python2.3/lib (or other dirs. Should I modify the file to use datetime.so instead? I'm not certain of the implications of that, but it doesn't seem like the correct move. I greatly appreciate your help. Don -- DC Parris GNU Evangelist http://matheteuo.org/ gnumathetes at gmail.com "Hey man, whatever pickles your list!" From jsaker at americanrelay.com Fri Jul 29 22:28:55 2005 From: jsaker at americanrelay.com (James Saker) Date: Fri, 29 Jul 2005 15:28:55 -0500 Subject: [DB-SIG] pygresql class field auto-generation Message-ID: <200507291528.55202.jsaker@americanrelay.com> Hello, I've been working with pygresql succesfully through a project that has a need for classes to mirror my postgresql tables while operating (it's a customer billing project). To this point, I've manually created classes like customer, product, subscription all manually by mirroring the structure of the postgresql table in a static class definition of the same name. Then I've built methods to initialize the objects after testing for valid criteria (e.g. valid integer value customer ID of ten digits before querying the database and populating the customer object). The real downside is that this takes forever, is terribly static and rather time consuming to build and maintain. Having read some of pg.DB's capabilities like get_attnames(table), and looking at a psycopg recipe with some similar capabilities, I was curious if anyone knew if a good pygresql class recipe I can inherit from that would provide this mechanism of getting all the attributes and automatically generating the object's attributes to match, along with other useful insertion/query methods. Jamie