From 230Deven at telepath.com Mon Feb 2 05:27:46 2004 From: 230Deven at telepath.com (Alfonso Angers) Date: Mon Feb 2 05:27:53 2004 Subject: [DB-SIG] Credit Declined, application fete punic vertigo bod hutchinson Message-ID: An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/db-sig/attachments/20040202/4158727a/attachment.html From ANTIGEN_LIB-EXCH at u.library.arizona.edu Tue Feb 3 03:43:44 2004 From: ANTIGEN_LIB-EXCH at u.library.arizona.edu (ANTIGEN_LIB-EXCH) Date: Tue Feb 3 03:44:02 2004 Subject: [DB-SIG] Antigen found VIRUS= Win32/Mydoom.A.Worm (CA(InoculateIT), Norman, Sophos) worm Message-ID: Antigen for Exchange found readme.zip->readme.scr infected with VIRUS= Win32/Mydoom.A.Worm (CA(InoculateIT),Norman,Sophos) worm. The message is currently Purged. The message, "Mail Transaction Failed", was sent from db-sig@python.org and was discovered in IMC Queues\Inbound located at Main Library/LIB-NT/LIB-EXCH. From iscan-mx1 at nhst.no Wed Feb 4 01:19:32 2004 From: iscan-mx1 at nhst.no (iscan-mx1@nhst.no) Date: Wed Feb 4 01:19:40 2004 Subject: [DB-SIG] Virus Alert Message-ID: <20040204061931.DF9BF2A0ABF@mx1.nhst.no> The mail message (file: message.cmd) you sent to russell.searancke@upstreamonline.com contains a virus. (on mx1) From postmaster at ndr.collegeclub.com Wed Feb 4 02:33:47 2004 From: postmaster at ndr.collegeclub.com (System Administrator) Date: Wed Feb 4 02:33:54 2004 Subject: [DB-SIG] Undeliverable: Test Message-ID: <6510490.1075880027811.JavaMail.Administrator@w3m-be> Your message To: matt@collegeclub.com Subject: Test was undeliverable due to the following reason: The person you are trying to e-mail has a full inbox. Please resend at a later time. matt@collegeclub.com x-sender:db-sig@python.org x-receiver:matt@collegeclub.com Received:from postfix6m.collegeclub.com ([10.209.68.80]) by smtp3m.collegeclub.com with Microsoft SMTPSVC(5.0.2195.6713); Wed, 4 Feb 2004 02:33:42 -0500 Received:from python.org (aasaserv.mlk.Arizona.EDU [150.135.21.40]) by postfix6m.collegeclub.com (Postfix) with ESMTP id BC2DDE79D3 for ; Wed, 4 Feb 2004 02:33:41 -0500 (EST) From:db-sig@python.org To:matt@collegeclub.com Subject:Test Date:Wed, 4 Feb 2004 00:51:51 -0700 MIME-Version:1.0 Content-Type:multipart/mixed; boundary="----=_NextPart_000_0006_9D7C82B5.863B45B8" X-Priority:3 X-MSMail-Priority:Normal Message-Id:<20040204073341.BC2DDE79D3@postfix6m.collegeclub.com> Return-Path:db-sig@python.org X-OriginalArrivalTime:04 Feb 2004 07:33:42.0546 (UTC) FILETIME=[36E45F20:01C3EAF1] From stuart.hungerford at anu.edu.au Wed Feb 4 23:41:16 2004 From: stuart.hungerford at anu.edu.au (Stuart Hungerford) Date: Wed Feb 4 23:41:05 2004 Subject: [DB-SIG] Question on shelve/pickle and namespaces... Message-ID: <6.0.0.22.0.20040205153748.01f17bb0@anusf.anu.edu.au> Hi all, I hope this is a suitable forum to ask this shelve related question: I figured if any group or SIG would know, it would be this one. I have a python module foo.py which contains: class A(object): ... class B(object): ... As well as a class that uses shelve (which in turn is using dumbdbm): class foo(object): ... // uses a shelve internally The methods of foo shelve and restore A and B instances *but* shelve seems to be looking in the wrong places for the definitions of A and B when they're "unshelved", giving the error: AttributeError: 'module' object has no attribute 'A' How can I persuade shelve to look in other namespaces for A and B? Any advice much appreciated, Cheers, Stu -- :: Stuart Hungerford (stuart.hungerford@anu.edu.au) :: ANU Internet Futures Group From chris at cogdon.org Thu Feb 5 00:00:36 2004 From: chris at cogdon.org (Chris Cogdon) Date: Thu Feb 5 00:00:45 2004 Subject: [DB-SIG] Question on shelve/pickle and namespaces... In-Reply-To: <6.0.0.22.0.20040205153748.01f17bb0@anusf.anu.edu.au> References: <6.0.0.22.0.20040205153748.01f17bb0@anusf.anu.edu.au> Message-ID: <3BF5CE6D-5798-11D8-B657-000A95E3823E@cogdon.org> On Feb 4, 2004, at 20:41, Stuart Hungerford wrote: > Hi all, > > I hope this is a suitable forum to ask this shelve related > question: I figured if any group or SIG would know, it would > be this one. > > I have a python module foo.py which contains: > > class A(object): ... > class B(object): ... > > As well as a class that uses shelve (which in turn is > using dumbdbm): > > class foo(object): ... > // uses a shelve internally > > The methods of foo shelve and restore A and B instances > *but* shelve seems to be looking in the wrong places for > the definitions of A and B when they're "unshelved", > giving the error: > > AttributeError: 'module' object has no attribute 'A' > > How can I persuade shelve to look in other namespaces for > A and B? > > Any advice much appreciated, Simply, make sure that the function or method that unshelves objects has the same namespace setup (with regards to classes and modules) as the setup that shelves them. The easiest way to do this is to have the shelving and unshelving in the same location, or nearly same location, in the code, such as putting all the shelving and unshelving into methods of the same class. -- ("`-/")_.-'"``-._ Chris Cogdon . . `; -._ )-;-,_`) (v_,)' _ )`-.\ ``-' _.- _..-_/ / ((.' ((,.-' ((,/ fL From pythontutor at venix.com Thu Feb 5 09:48:46 2004 From: pythontutor at venix.com (Lloyd Kvam) Date: Thu Feb 5 09:49:04 2004 Subject: [DB-SIG] Question on shelve/pickle and namespaces... In-Reply-To: <3BF5CE6D-5798-11D8-B657-000A95E3823E@cogdon.org> References: <6.0.0.22.0.20040205153748.01f17bb0@anusf.anu.edu.au> <3BF5CE6D-5798-11D8-B657-000A95E3823E@cogdon.org> Message-ID: <402257CE.2050005@venix.com> Chris Cogdon wrote: > > On Feb 4, 2004, at 20:41, Stuart Hungerford wrote: > >> Hi all, >> >> I hope this is a suitable forum to ask this shelve related >> question: I figured if any group or SIG would know, it would >> be this one. >> >> I have a python module foo.py which contains: >> >> class A(object): ... >> class B(object): ... >> >> As well as a class that uses shelve (which in turn is >> using dumbdbm): >> >> class foo(object): ... >> // uses a shelve internally >> >> The methods of foo shelve and restore A and B instances >> *but* shelve seems to be looking in the wrong places for >> the definitions of A and B when they're "unshelved", >> giving the error: >> >> AttributeError: 'module' object has no attribute 'A' >> >> How can I persuade shelve to look in other namespaces for >> A and B? >> >> Any advice much appreciated, > > > Simply, make sure that the function or method that unshelves objects has > the same namespace setup (with regards to classes and modules) as the > setup that shelves them. The easiest way to do this is to have the > shelving and unshelving in the same location, or nearly same location, > in the code, such as putting all the shelving and unshelving into > methods of the same class. > > If Chris's advice is not so easy to follow, I'd suggest: import ABmodule; A = ABmodule.A; B = ABmodule.B -- Lloyd Kvam Venix Corp. 1 Court Street, Suite 378 Lebanon, NH 03766-1358 voice: 603-653-8139 fax: 801-459-9582 -- Lloyd Kvam Venix Corp. 1 Court Street, Suite 378 Lebanon, NH 03766-1358 voice: 603-653-8139 fax: 801-459-9582 From mcolosimo at mitre.org Mon Feb 9 15:44:45 2004 From: mcolosimo at mitre.org (Marc Colosimo) Date: Mon Feb 9 15:45:42 2004 Subject: [DB-SIG] PyGreSQL and NULLs Message-ID: I hope this list is alive. The DB-API 2.0 document says that "SQL NULL values are represented by Python None signleton on imput and output" under Type Objects and Constructors. However, when passing in a None object using the pyformat it replaces it with a blank string. for example, my_user = {"id":10,"name":"Marc"} cursor.execute("INSERT into myTable (my_id, my_name, my_pet_id) values " + "(%(id)s,'%(name)s',%(pet)s) % my_user) would result in this SQL command, INSERT into myTable (my_id, my_name, my_pet_id) values (10, 'Marc', ); instead of this one INSERT into myTable (my_id, my_name, my_pet_id) values (10, 'Marc', NULL); is this a known problem? Thanks Marc From James.Briggs at unisuper.com.au Tue Feb 10 00:27:31 2004 From: James.Briggs at unisuper.com.au (James Briggs) Date: Tue Feb 10 00:28:26 2004 Subject: [DB-SIG] Using callproc with OUTPUT parameters Message-ID: I am connecting to a MS SQL Server database, and I wish to execute a stored procedure that can perform various transactions in the database. The tricky bit is I wish the stored procedure to return a value to a python variable. As a very simple example, the SQL Server code could be: DROP PROCEDURE test_inc GO CREATE PROCEDURE test_inc (@a int, @b int OUTPUT) AS BEGIN SET @b=@a+1 END GO I have happily used mx.ODBC in the past, but this API doesn't provide the cursor.callproc method. I can call the procedure with code like this, but how can I access the output value? >>> from mx.ODBC.Windows import connect >>> db=connect('IPUAT6',user='x',password='x') >>> a=1 >>> b=0 >>> c=db.cursor() >>> c.execute('exec dbo.test_inc ?, ? output', (a,b)) 1 >>> c.fetchall() Traceback (most recent call last): File "", line 1, in ? ProgrammingError: missing result set >>> Alternatively using callproc in the adodbapi module the procedure executes, but I do not see any variables updated: >>> from adodbapi import connect >>> db=connect('Driver={SQL Server};server=%s;Database=%s;UID=%s;PWD=%s;'%('SERVER','ipuat6','x','x')) >>> a=1 >>> b=0 >>> c=db.cursor() >>> c.callproc('test_inc',[a,b]) [1, 0] >>> (a,b) (1, 0) >>> c.fetchone() Traceback (most recent call last): File "", line 1, in ? File "D:\PYTHON23\Lib\site-packages\adodbapi\adodbapi.py", line 654, in fetchone ret = self._fetch(1) File "D:\PYTHON23\Lib\site-packages\adodbapi\adodbapi.py", line 623, in _fetch self._raiseCursorError(Error,None) File "D:\PYTHON23\Lib\site-packages\adodbapi\adodbapi.py", line 407, in _raiseCursorError eh(self.conn,self,errorclass,errorvalue) File "D:\PYTHON23\Lib\site-packages\adodbapi\adodbapi.py", line 38, in standardErrorHandler raise errorclass(errorvalue) Error: None My questions in a nutshell are: Am I using callproc correctly here? Is there API that connects to SQL Server where callproc works with output parameters? James Briggs "This e-mail message is intended only for the addressee(s) and contains information which may be confidential. If you are not the intended recipient please advise the sender by return email, do not use or disclose the contents, and delete the message and any attachments from your system. Unless specifically indicated, this email does not constitute formal advice or commitment by the sender or UniSuper (ABN 54 006 027 121) or its subsidiaries." From chris at cogdon.org Tue Feb 10 00:35:12 2004 From: chris at cogdon.org (Chris Cogdon) Date: Tue Feb 10 00:35:23 2004 Subject: [DB-SIG] Using callproc with OUTPUT parameters In-Reply-To: References: Message-ID: On Feb 9, 2004, at 21:27, James Briggs wrote: > My questions in a nutshell are: > Am I using callproc correctly here? > Is there API that connects to SQL Server where callproc works with > output parameters? Try, simply, calling the procedure as part of a select statement. Select is the standard way of passing information back to the DB client. Eg: Select 1+2; Or, Select yourfunction ( 3, 4, 5 ); -- ("`-/")_.-'"``-._ Chris Cogdon . . `; -._ )-;-,_`) (v_,)' _ )`-.\ ``-' _.- _..-_/ / ((.' ((,.-' ((,/ fL From listguru at fatcity.com Tue Feb 10 01:44:01 2004 From: listguru at fatcity.com (listguru@fatcity.com) Date: Tue Feb 10 01:47:12 2004 Subject: [DB-SIG] Response to your ListGuru session [MsgId AA20040209.224401.2] Message-ID: <1076395442@fatcity.com> -- Your message was directed to ListGuru for processing, but it did not appear to contain any ListGuru commands. You must put all commands in the message BODY and your message needs to be sent in PLAIN TEXT, not HTML, rich text or any other form of encoding. Only plain-text messages will be interpreted. If you have further problems with commands, and/or are unable to achieve the result you desire, send an E-mail message to: ListMaster@fatcity.com From jagarenbraperson at yahoo.se Tue Feb 10 05:02:51 2004 From: jagarenbraperson at yahoo.se (=?iso-8859-1?q?Henrik=20Ekelund?=) Date: Tue Feb 10 05:02:56 2004 Subject: [DB-SIG] Using callproc with OUTPUT parameters In-Reply-To: Message-ID: <20040210100251.49513.qmail@web13309.mail.yahoo.com> Yes to both questions: you are using callproc correctly, and adodbapi works with output paramters and SQL Server. The problem is with the driver. Your connectionstring uses the ODBC driver for SQL Server. If you use the OLE DB driver instead it works correctly. Change your connect statement to this: db=connect('Provider=SQLOLEDB.1;Data Source=%s; Initial Catalog=%s;User ID=%s;Password=%s;' %('SERVER','ipuat6','x','x')) and I'm pretty sure it will work. There is a testcase for output parameters called testVariableReturningStoredProcedure in the file adodbapitest.py More about the connect string syntax: http://www.connectionstrings.com /Henrik Ekelund --- James Briggs skrev: > > > I am connecting to a MS SQL Server database, and I > wish to execute a stored procedure that can perform > various transactions in the database. > The tricky bit is I wish the stored procedure to > return a value to a python variable. > > As a very simple example, the SQL Server code could > be: > > DROP PROCEDURE test_inc > GO > > CREATE PROCEDURE test_inc (@a int, @b int OUTPUT) > AS > BEGIN > SET @b=@a+1 > END > GO > > I have happily used mx.ODBC in the past, but this > API doesn't provide the cursor.callproc method. > I can call the procedure with code like this, but > how can I access the output value? > > >>> from mx.ODBC.Windows import connect > >>> db=connect('IPUAT6',user='x',password='x') > >>> a=1 > >>> b=0 > >>> c=db.cursor() > >>> c.execute('exec dbo.test_inc ?, ? output', > (a,b)) > 1 > >>> c.fetchall() > Traceback (most recent call last): > File "", line 1, in ? > ProgrammingError: missing result set > >>> > > Alternatively using callproc in the adodbapi module > the procedure executes, but I do not see any > variables updated: > > >>> from adodbapi import connect > >>> db=connect('Driver={SQL > Server};server=%s;Database=%s;UID=%s;PWD=%s;'%('SERVER','ipuat6','x','x')) > >>> a=1 > >>> b=0 > >>> c=db.cursor() > >>> c.callproc('test_inc',[a,b]) > [1, 0] > >>> (a,b) > (1, 0) > >>> c.fetchone() > Traceback (most recent call last): > File "", line 1, in ? > File > "D:\PYTHON23\Lib\site-packages\adodbapi\adodbapi.py", > line 654, in fetchone > ret = self._fetch(1) > File > "D:\PYTHON23\Lib\site-packages\adodbapi\adodbapi.py", > line 623, in _fetch > self._raiseCursorError(Error,None) > File > "D:\PYTHON23\Lib\site-packages\adodbapi\adodbapi.py", > line 407, in _raiseCursorError > eh(self.conn,self,errorclass,errorvalue) > File > "D:\PYTHON23\Lib\site-packages\adodbapi\adodbapi.py", > line 38, in standardErrorHandler > raise errorclass(errorvalue) > Error: None > > > My questions in a nutshell are: > Am I using callproc correctly here? > Is there API that connects to SQL Server where > callproc works with output parameters? > > James Briggs > > > "This e-mail message is intended only for the > addressee(s) > and contains information which may be confidential. > If > you are not the intended recipient please advise > the > sender by return email, do not use or disclose the > contents, and delete the message and any > attachments > from your system. Unless specifically indicated, > this > email does not constitute formal advice or > commitment > by the sender or UniSuper (ABN 54 006 027 121) or > its > subsidiaries." > > _______________________________________________ > DB-SIG maillist - DB-SIG@python.org > http://mail.python.org/mailman/listinfo/db-sig H?strusk och gr? moln - k?p en resa till solen p? Yahoo! Resor p? adressen http://se.docs.yahoo.com/travel/index.html From andy47 at halfcooked.com Tue Feb 10 10:04:12 2004 From: andy47 at halfcooked.com (Andy Todd) Date: Tue Feb 10 10:09:55 2004 Subject: [Fwd: Re: [DB-SIG] PyGreSQL and NULLs] Message-ID: <4028F2EC.5070903@halfcooked.com> Oops, forgot to cc the list. Regards, Andy -- -------------------------------------------------------------------------------- From the desk of Andrew J Todd esq - http://www.halfcooked.com/ -------------- next part -------------- An embedded message was scrubbed... From: Andy Todd Subject: Re: [DB-SIG] PyGreSQL and NULLs Date: Tue, 10 Feb 2004 09:51:05 +0000 Size: 1776 Url: http://mail.python.org/pipermail/db-sig/attachments/20040210/b0359655/DB-SIGPyGreSQLandNULLs.mht From ods at strana.ru Tue Feb 10 13:14:54 2004 From: ods at strana.ru (Denis S. Otkidach) Date: Tue Feb 10 13:15:05 2004 Subject: [DB-SIG] PyGreSQL and NULLs In-Reply-To: <4028A989.2040302@halfcooked.com> Message-ID: On Tue, 10 Feb 2004, Andy Todd wrote: AT> > my_user = {"id":10,"name":"Marc"} AT> > AT> > cursor.execute("INSERT into myTable (my_id, my_name, AT> my_pet_id) values " + AT> > "(%(id)s,'%(name)s',%(pet)s) % my_user) AT> > AT> > would result in this SQL command, AT> > AT> > INSERT into myTable (my_id, my_name, my_pet_id) values AT> (10, 'Marc', ); [...] AT> AT> I don't have Postgres or PyGreSQL installed but I suspect AT> that if you AT> change the first line to; AT> AT> my_user = {'id':10, 'name':'Marc', 'pet':None} AT> AT> You would get the result you are expecting. No, Python formating operator know nothing about DB API and cannot transfrom None to 'NULL'. There are several errors in original sample: - no quote at the and of format string (leads to SyntaxError); - no value with key 'pet' (leads to KeyError); - Python formating operator % is used instead of passing parameters as second argument of execute. -- Denis S. Otkidach http://www.python.ru/ [ru] From dieter at handshake.de Tue Feb 10 13:56:59 2004 From: dieter at handshake.de (Dieter Maurer) Date: Tue Feb 10 14:10:03 2004 Subject: [DB-SIG] PyGreSQL and NULLs In-Reply-To: References: Message-ID: <16425.10619.945049.427743@gargle.gargle.HOWL> Marc Colosimo wrote at 2004-2-9 15:44 -0500: >I hope this list is alive. The DB-API 2.0 document says that "SQL NULL >values are represented by Python None signleton on imput and output" >under Type Objects and Constructors. However, when passing in a None >object using the pyformat it replaces it with a blank string. > >for example, > >my_user = {"id":10,"name":"Marc"} > >cursor.execute("INSERT into myTable (my_id, my_name, my_pet_id) values >" + > "(%(id)s,'%(name)s',%(pet)s) % my_user) > >would result in this SQL command, > >INSERT into myTable (my_id, my_name, my_pet_id) values (10, 'Marc', ); > >instead of this one > >INSERT into myTable (my_id, my_name, my_pet_id) values (10, 'Marc', >NULL); > >is this a known problem? What happens when you use my_user = {"id":10,"name":"Marc", "pet":None,} ? -- Dieter From mcolosimo at mitre.org Tue Feb 10 16:49:07 2004 From: mcolosimo at mitre.org (Marc Colosimo) Date: Tue Feb 10 16:49:23 2004 Subject: [DB-SIG] PyGreSQL and NULLs In-Reply-To: <4028A989.2040302@halfcooked.com> References: <4028A989.2040302@halfcooked.com> Message-ID: On Feb 10, 2004, at 4:51 AM, Andy Todd wrote: > Marc Colosimo wrote: >> I hope this list is alive. The DB-API 2.0 document says that "SQL >> NULL values are represented by Python None signleton on imput and >> output" under Type Objects and Constructors. However, when passing in >> a None object using the pyformat it replaces it with a blank string. >> for example, >> my_user = {"id":10,"name":"Marc"} >> cursor.execute("INSERT into myTable (my_id, my_name, my_pet_id) >> values " + >> "(%(id)s,'%(name)s',%(pet)s) % my_user) >> would result in this SQL command, >> INSERT into myTable (my_id, my_name, my_pet_id) values (10, 'Marc', ); >> instead of this one >> INSERT into myTable (my_id, my_name, my_pet_id) values (10, 'Marc', >> NULL); >> is this a known problem? >> Thanks >> Marc > > I don't have Postgres or PyGreSQL installed but I suspect that if you > change the first line to; > > my_user = {'id':10, 'name':'Marc', 'pet':None} > > You would get the result you are expecting. > oops, I forgot to add that in my pseudo code. Here is a real example. As you see it puts in None, instead of Null. If I change "pet":None to "pet":"Null" it works. %psql test test=# CREATE TABLE myTable ( test(# my_id INTEGER, test(# my_name TEXT, test(# my_pet_id INTEGER); CREATE TABLE Now for my_test.py !#/usr/bin/env python import pgdb db = pgdb.connect(database="test") cursor = db.cursor() my_user = {"id":10,"name":"Marc","pet":None} cursor.execute("INSERT into myTable (my_id, my_name, my_pet_id) values " + "(%(id)s,'%(name)s',%(pet)s)" % my_user) db.commit() cursor.close() db.close() % ./my_test.py Traceback (most recent call last): File "my_test.py", line 8, in ? cursor.execute("INSERT into myTable (my_id, my_name, my_pet_id) values " + File "/sw/lib/python2.3/site-packages/pgdb.py", line 189, in execute self.executemany(operation, (params,)) File "/sw/lib/python2.3/site-packages/pgdb.py", line 208, in executemany raise DatabaseError, "error '%s' in '%s'" % ( msg, sql ) pgdb.DatabaseError: error 'ERROR: Attribute "none" not found ' in 'INSERT into myTable (my_id, my_name, my_pet_id) values (10,'Marc',None)' From chris at cogdon.org Tue Feb 10 17:01:07 2004 From: chris at cogdon.org (Chris Cogdon) Date: Tue Feb 10 17:06:41 2004 Subject: [DB-SIG] PyGreSQL and NULLs In-Reply-To: References: <4028A989.2040302@halfcooked.com> Message-ID: On Feb 10, 2004, at 13:49, Marc Colosimo wrote: > oops, I forgot to add that in my pseudo code. Here is a real example. > As you see it puts in None, instead of Null. If I change "pet":None to > "pet":"Null" it works. Actually, you'll find that it doesn't work. It inserts the string "Null" rather than the 'null object', which are very, very different. I would actually consider this to be a 'misfeature' that the data type converter does not convert the python None object into the DB NULL object. -- ("`-/")_.-'"``-._ Chris Cogdon . . `; -._ )-;-,_`) (v_,)' _ )`-.\ ``-' _.- _..-_/ / ((.' ((,.-' ((,/ fL From mcolosimo at mitre.org Tue Feb 10 17:20:00 2004 From: mcolosimo at mitre.org (Marc Colosimo) Date: Tue Feb 10 17:20:16 2004 Subject: [DB-SIG] PyGreSQL and NULLs In-Reply-To: References: <4028A989.2040302@halfcooked.com> Message-ID: <44414054-5C17-11D8-B594-000A95A5D8B2@mitre.org> On Feb 10, 2004, at 5:01 PM, Chris Cogdon wrote: > > On Feb 10, 2004, at 13:49, Marc Colosimo wrote: > >> oops, I forgot to add that in my pseudo code. Here is a real example. >> As you see it puts in None, instead of Null. If I change "pet":None >> to "pet":"Null" it works. > > Actually, you'll find that it doesn't work. It inserts the string > "Null" rather than the 'null object', which are very, very different. > > I would actually consider this to be a 'misfeature' that the data type > converter does not convert the python None object into the DB NULL > object. > > I changed the table for my_pet_id to: my_pet_id INTEGER UNIQUE then added another person: my_user = {"id":11,"name":"Chris","pet":"Null"} %psql test test=# select * from mytable ; my_id | my_name | my_pet_id -------+---------+----------- 10 | Marc | 11 | Chris | (2 rows) Better yet, test=# select * from mytable where my_pet_id IS NULL; my_id | my_name | my_pet_id -------+---------+----------- 10 | Marc | 11 | Chris | (2 rows) Marc From dyoo at hkn.eecs.berkeley.edu Tue Feb 10 17:17:55 2004 From: dyoo at hkn.eecs.berkeley.edu (Danny Yoo) Date: Tue Feb 10 17:23:40 2004 Subject: [DB-SIG] PyGreSQL and NULLs In-Reply-To: Message-ID: On Tue, 10 Feb 2004, Marc Colosimo wrote: > oops, I forgot to add that in my pseudo code. Here is a real example. > As you see it puts in None, instead of Null. If I change "pet":None to > "pet":"Null" it works. > > %psql test > test=# CREATE TABLE myTable ( > test(# my_id INTEGER, > test(# my_name TEXT, > test(# my_pet_id INTEGER); > CREATE TABLE > > Now for my_test.py > !#/usr/bin/env python > > import pgdb > > db = pgdb.connect(database="test") > cursor = db.cursor() > > my_user = {"id":10,"name":"Marc","pet":None} > > cursor.execute("INSERT into myTable (my_id, my_name, my_pet_id) values > " + > "(%(id)s,'%(name)s',%(pet)s)" % my_user) ^^^^^^^^^ Hi Marc, Don't do that. *grin* Send cursor.execute a second parameter --- that dictionary 'my_user' --- and let the driver do the interpolation for you. ### >>> import pgdb >>> conn = pgdb.connect(database='dyoo') >>> cursor = conn.cursor() >>> my_user = {'id' : 10, 'name' : 'dyoo', 'pet' : None} >>> cursor.execute('''insert into myTable (my_id, my_name, my_pet_id) ... values (%(id)s, %(name)s, %(pet)s)''', ... my_user) >>> conn.commit() ### Do not try to do the interpolation yourself: let the database handler do it. Hope this helps! From sakesun at boonthavorn.com Tue Feb 10 21:03:04 2004 From: sakesun at boonthavorn.com (Sake) Date: Tue Feb 10 21:03:35 2004 Subject: [DB-SIG] RE: PyGreSQL and NULLs In-Reply-To: References: Message-ID: <40298D58.7080101@boonthavorn.com> Try cursor.execute("insert into myTable(my_id, my_name, my_ped_id) values (?,?,?)", [10, "Marc", None]) From mcolosimo at mitre.org Wed Feb 11 10:45:33 2004 From: mcolosimo at mitre.org (Marc Colosimo) Date: Wed Feb 11 10:45:48 2004 Subject: [DB-SIG] PyFormat and execute In-Reply-To: References: Message-ID: <53D6CD68-5CA9-11D8-B594-000A95A5D8B2@mitre.org> On Feb 10, 2004, at 5:17 PM, Danny Yoo wrote: >> !#/usr/bin/env python >> >> import pgdb >> >> db = pgdb.connect(database="test") >> cursor = db.cursor() >> >> my_user = {"id":10,"name":"Marc","pet":None} >> >> cursor.execute("INSERT into myTable (my_id, my_name, my_pet_id) values >> " + >> "(%(id)s,'%(name)s',%(pet)s)" % my_user) > ^^^^^^^^^ > Hi Marc, > > Don't do that. *grin* > > Send cursor.execute a second parameter --- that dictionary 'my_user' > --- > and let the driver do the interpolation for you. > > ### >>>> import pgdb >>>> conn = pgdb.connect(database='dyoo') >>>> cursor = conn.cursor() >>>> my_user = {'id' : 10, 'name' : 'dyoo', 'pet' : None} >>>> cursor.execute('''insert into myTable (my_id, my_name, my_pet_id) > ... values (%(id)s, %(name)s, %(pet)s)''', > ... my_user) >>>> conn.commit() > ### > > Do not try to do the interpolation yourself: let the database handler > do > it. > Hi Danny, Wow! Why isn't there a DB FAQ with this in it? I was just using the PyFormat and really didn't understand that the DB-API can handle the interpolation for me. I now understand what the [5] next to the description for execute was describing. Does this also escape naughty SQL characters like ' and \ in strings? And how can one use the type objects to send NUMBERS, DATETIME objects? Thanks, Marc From andy47 at halfcooked.com Wed Feb 11 11:41:31 2004 From: andy47 at halfcooked.com (Andy Todd) Date: Wed Feb 11 11:47:19 2004 Subject: [DB-SIG] PyFormat and execute In-Reply-To: <53D6CD68-5CA9-11D8-B594-000A95A5D8B2@mitre.org> References: <53D6CD68-5CA9-11D8-B594-000A95A5D8B2@mitre.org> Message-ID: <402A5B3B.8070905@halfcooked.com> Marc Colosimo wrote: [snip] >> >> Do not try to do the interpolation yourself: let the database handler do >> it. >> > Hi Danny, > > Wow! Why isn't there a DB FAQ with this in it? I was just using the > PyFormat and really didn't understand that the DB-API can handle the > interpolation for me. I now understand what the [5] next to the > description for execute was describing. > > Does this also escape naughty SQL characters like ' and \ in strings? > > And how can one use the type objects to send NUMBERS, DATETIME objects? > > Thanks, > Marc > Yes, and yes to your last two questions. It is in the DB-API specification, its just not incredibly obvious to the newcomer. To that end I created a page on the Python Wiki and made this FAQ number 1; http://www.python.org/cgi-bin/moinmoin/DbApiFaq If anyone wants to improve my wording feel free. Regards, Andy -- -------------------------------------------------------------------------------- From the desk of Andrew J Todd esq - http://www.halfcooked.com/ From H.Duerer at gmx.net Wed Feb 11 15:35:02 2004 From: H.Duerer at gmx.net (Holger Duerer) Date: Wed Feb 11 15:50:29 2004 Subject: [DB-SIG] Re: PyFormat and execute References: <53D6CD68-5CA9-11D8-B594-000A95A5D8B2@mitre.org> <402A5B3B.8070905@halfcooked.com> Message-ID: <87znbp9wy1.fsf@Ronaldann.demon.co.uk> >>>>> "Andy" == Andy Todd writes: [...] Andy> Yes, and yes to your last two questions. It is in the DB-API Andy> specification, its just not incredibly obvious to the Andy> newcomer. Andy> To that end I created a page on the Python Wiki and made Andy> this FAQ number 1; Andy> http://www.python.org/cgi-bin/moinmoin/DbApiFaq Andy> If anyone wants to improve my wording feel free. Yes, it is shocking that this feature is not more widely known. Most examples of DB access code that I have seen use the literal approach of adding the value in the SQL statement itself -- this is of course a SQL injection attack waiting to happen for all those people who just copy such code... All example programs should only show the execute method with arguments provided separately. Holger From rjshaw at iprimus.com.au Wed Feb 11 22:41:13 2004 From: rjshaw at iprimus.com.au (Russell Shaw) Date: Wed Feb 11 22:41:20 2004 Subject: [DB-SIG] Can't connect Message-ID: <402AF5D9.6080503@iprimus.com.au> Hi, I just learnt python. In my python file, i have: from pyPgSQL import libpq ... conn=connect(host="localhost",database="parts",user="russell") I get an error. python db.py: Traceback (most recent call last): File "db.py", line 108, in ? conn=connect(host="localhost",database="parts",user="russell") NameError: name 'connect' is not defined Where can i find the functions defined in libpq? (i'm using debian) From chris at cogdon.org Wed Feb 11 22:46:52 2004 From: chris at cogdon.org (Chris Cogdon) Date: Wed Feb 11 22:46:57 2004 Subject: [DB-SIG] Can't connect In-Reply-To: <402AF5D9.6080503@iprimus.com.au> References: <402AF5D9.6080503@iprimus.com.au> Message-ID: <18641A25-5D0E-11D8-8A15-000A95E3823E@cogdon.org> On Feb 11, 2004, at 19:41, Russell Shaw wrote: > Hi, > I just learnt python. In my python file, > i have: > > from pyPgSQL import libpq > ... > conn=connect(host="localhost",database="parts",user="russell") > > > I get an error. python db.py: > > Traceback (most recent call last): > File "db.py", line 108, in ? > conn=connect(host="localhost",database="parts",user="russell") > NameError: name 'connect' is not defined Try: conn = libpq.connect ( ... The general rule is, when you 'import' something, you have to keep using that name. So if you: import X Then you need to say X.this and X.that Or, if you: from X import this, that then you can use 'this' and 'that' without having to say X. -- ("`-/")_.-'"``-._ Chris Cogdon . . `; -._ )-;-,_`) (v_,)' _ )`-.\ ``-' _.- _..-_/ / ((.' ((,.-' ((,/ fL From rjshaw at iprimus.com.au Wed Feb 11 23:21:52 2004 From: rjshaw at iprimus.com.au (Russell Shaw) Date: Wed Feb 11 23:22:00 2004 Subject: [DB-SIG] Can't connect In-Reply-To: <18641A25-5D0E-11D8-8A15-000A95E3823E@cogdon.org> References: <402AF5D9.6080503@iprimus.com.au> <18641A25-5D0E-11D8-8A15-000A95E3823E@cogdon.org> Message-ID: <402AFF60.2050600@iprimus.com.au> Chris Cogdon wrote: > > On Feb 11, 2004, at 19:41, Russell Shaw wrote: > >> Hi, >> I just learnt python. In my python file, >> i have: >> >> from pyPgSQL import libpq >> ... >> conn=connect(host="localhost",database="parts",user="russell") >> >> >> I get an error. python db.py: >> >> Traceback (most recent call last): >> File "db.py", line 108, in ? >> conn=connect(host="localhost",database="parts",user="russell") >> NameError: name 'connect' is not defined > > > Try: > > conn = libpq.connect ( ... > > The general rule is, when you 'import' something, you have to keep > using that name. So if you: > > import X > > Then you need to say X.this and X.that > > Or, if you: > > from X import this, that > > then you can use 'this' and 'that' without having to say X. Thanks, i've read that in the manual. I got it working now. It took me a while to figure out there's two interfaces (libpq and PgSQL;) From chris at cogdon.org Wed Feb 11 23:34:04 2004 From: chris at cogdon.org (Chris Cogdon) Date: Wed Feb 11 23:34:09 2004 Subject: [DB-SIG] Can't connect In-Reply-To: <402AFF60.2050600@iprimus.com.au> References: <402AF5D9.6080503@iprimus.com.au> <18641A25-5D0E-11D8-8A15-000A95E3823E@cogdon.org> <402AFF60.2050600@iprimus.com.au> Message-ID: On Feb 11, 2004, at 20:21, Russell Shaw wrote: > Thanks, i've read that in the manual. I got it working now. It took me > a while to figure out there's two interfaces (libpq and PgSQL;) There's several more than that. psycopg comes to mind :) -- ("`-/")_.-'"``-._ Chris Cogdon . . `; -._ )-;-,_`) (v_,)' _ )`-.\ ``-' _.- _..-_/ / ((.' ((,.-' ((,/ fL From mcolosimo at mitre.org Thu Feb 12 10:32:47 2004 From: mcolosimo at mitre.org (Marc Colosimo) Date: Thu Feb 12 10:32:56 2004 Subject: [DB-SIG] How to use DATETIME objects (and other Type Objects)? Message-ID: Now that I understand how to use the executeXXX(), I would like to know how to pass in specific type objects to executeXXX() and how to receive them back from fetchXXX(). For example, if I have a table with a DATETIME format how can I send it in the correct format to executeXXX()? Or if my table has numberic column, how do I use NUMBER Type object to specify this? Thanks, Marc From 12wbrcxq at ez-poa.com.br Thu Feb 12 08:38:26 2004 From: 12wbrcxq at ez-poa.com.br (Eduardo Villanueva) Date: Thu Feb 12 10:43:40 2004 Subject: [DB-SIG] Learn how to make big profits with Google Message-ID: <1c-0b6n-4-60-$26-1@56m.7v.n0q> An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/db-sig/attachments/20040212/d5d6b3f2/attachment.html From michael at hobbshouse.org Thu Feb 12 14:10:15 2004 From: michael at hobbshouse.org (Michael Hobbs) Date: Thu Feb 12 14:10:43 2004 Subject: [DB-SIG] Table Oriented Programming Message-ID: <000a01c3f19b$dc5c7ea0$0a0aa8c0@mikesmonster> Yeah, yeah, another X-Oriented paradigm, but please hear me out. I have recently been studying up on EJB's in order to extend my resume. I have looked at J2EE several times over the past years, but have never been impressed by it. Now that I've studied it in detail, I know why. A strongly typed language such as Java is poorly suited to model tables and relations. I got to thinking that a more dynamically typed language, such as Python, would be a more natural fit. I've always been fond of the table-oriented programming ideas described in http://www.geocities.com/tablizer/top.htm, so I'm thinking that if Python could be extended to handle table-oriented programming as seamlessly as it handles object-oriented programming, it could become a really valuable language for writing enterprise components, a la EJB. Does anyone know if anyone has already walked this path? I've given it a little thought myself, and here are some of my [incomplete] ideas: - Tables would be first-class values, just as classes are. - A table may be stored completely in memory, or it may represent a table stored in a database engine. - A table may represent the result of a query. - Queries are performed using a sequence of operators, rather than relying on SQL. Consider this example code: departments = DepartmentTable employees = EmployeeTable johnsDepartment = (departments * employees) / (employees.dept == departments.dept) / (employees.name == 'John') % departments.name print johnsDepartment[0].name In the code above, the "*" operator performs a cartesian product, the "/" operator performs a selection, and the "%" operator performs a projection. If the DepartmentTable and the EmployeeTable are stored in a database engine, the expression above would generate a SQL query similar to "select department.name from (select * from department, employee where employee.dept = department.dept) where employee.name = 'John'". If the expression had been written "(departments * employees) / (employees.dept == departments.dept and employees.name == 'John') % departments.name", the resulting SQL would be similar to "select department.name from department, employee where employee.dept = department.dept and employee.name = 'John'", that is, without the nested SELECT. Of course, the entire code above could be reduced to a single line: print ((DepartmentTable * EmployeeTable) / (EmployeeTable.dept == DepartmentTable.dept and EmployeeTable.name == 'John') % DepartmentTable.name)[0].name Perhaps the list-comprehension syntax may be better suited than arithmetic operators. Like I said, my ideas are still a little incomplete. Please forgive me if this has already been discussed to death, - Michael Hobbs From skip at pobox.com Thu Feb 12 14:54:25 2004 From: skip at pobox.com (Skip Montanaro) Date: Thu Feb 12 14:55:03 2004 Subject: [DB-SIG] Re: Table Oriented Programming In-Reply-To: <000a01c3f19b$dc5c7ea0$0a0aa8c0@mikesmonster> References: <000a01c3f19b$dc5c7ea0$0a0aa8c0@mikesmonster> Message-ID: <16427.55793.980420.852897@montanaro.dyndns.org> Michael> I got to thinking that a more dynamically typed language, such Michael> as Python, would be a more natural fit. I've always been fond Michael> of the table-oriented programming ideas described in Michael> http://www.geocities.com/tablizer/top.htm, so I'm thinking that Michael> if Python could be extended to handle table-oriented Michael> programming as seamlessly as it handles object-oriented Michael> programming, it could become a really valuable language for Michael> writing enterprise components, a la EJB. Michael> Does anyone know if anyone has already walked this path? Maybe you could start with one of the various object-relational mappers available for Python then implement cartesion products, selection and projection in them by overriding "*", "/" and "%" as appropriate. Skip From mcolosimo at mitre.org Fri Feb 13 10:19:45 2004 From: mcolosimo at mitre.org (Marc Colosimo) Date: Fri Feb 13 10:20:53 2004 Subject: [DB-SIG] How to use DATETIME objects (and other Type Objects)? In-Reply-To: References: Message-ID: <0E060EF0-5E38-11D8-A640-000A95A5D8B2@mitre.org> On Feb 12, 2004, at 10:32 AM, Marc Colosimo wrote: > Now that I understand how to use the executeXXX(), I would like to > know how to pass in specific type objects to executeXXX() and how to > receive them back from fetchXXX(). > > For example, if I have a table with a DATETIME format how can I send > it in the correct format to executeXXX()? Or if my table has numberic > column, how do I use NUMBER Type object to specify this? > > Okay, it must be a slow brain week for me. After looking at some driver code I see that I completely missed the point about what NUMBER, DATETIME, etc are used for. My basic question was if I had a real or numeric field in my database, how do I tell the driver that it needs to send that. The answer is as before, let the drive handle that: import pgdb cursor.execute("INSERT INTO mytable (my_id, my_real, my_date) VALUES (%s, %s, %s)", (2, 10.2, "now")) cursor.execute("SELECT my_real, my_date) FROM mytable WHERE my_id = 2") fetchedL = cursor.fetchone() print fetchedL prints this [10.199999999999999, '2004-02-13 10:05:57.343744'] but, print fetchedL[0] prints, 10.2 Also, if type(clist[0]) == pgdb.FLOAT: print "First argument is a pgdb FLOAT" if type(clist[1]) == float: print "First argument is a python float" Only print's that this is a python float. When would one use something like pgdb.FLOAT? Marc From ods at strana.ru Fri Feb 13 11:54:39 2004 From: ods at strana.ru (Denis S. Otkidach) Date: Fri Feb 13 11:54:55 2004 Subject: [DB-SIG] How to use DATETIME objects (and other Type Objects)? In-Reply-To: <0E060EF0-5E38-11D8-A640-000A95A5D8B2@mitre.org> Message-ID: On Fri, 13 Feb 2004, Marc Colosimo wrote: MC> When would one use something like pgdb.FLOAT? To compare with values in cursor.description. In most cases you don't need it. -- Denis S. Otkidach http://www.python.ru/ [ru] From MAILsweeper at sherryfitz.ie Fri Feb 13 20:04:28 2004 From: MAILsweeper at sherryfitz.ie (MAILsweeper@sherryfitz.ie) Date: Fri Feb 13 20:06:47 2004 Subject: [DB-SIG] Virus detected in Virus sent to Sherry FitzGerald Group Message-ID: From: db-sig@python.org To: jane@sherryfitz.ie Date: Fri, 13 Feb 2004 19:06:02 -0600 Re: TEST This message has been scanned and has been determined to have a virus infected attachment. Accordingly this message has not been forwarded to the recipient. Sender, please remove the virus from your system and resend the message. From 06lsqvdie at informatik.fh-fulda.de Fri Feb 13 16:33:49 2004 From: 06lsqvdie at informatik.fh-fulda.de (Beryl Burger) Date: Fri Feb 13 20:40:57 2004 Subject: [DB-SIG] No more scams Message-ID: An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/db-sig/attachments/20040213/a0983b17/attachment-0001.html From frederik.wenz at 12move.de Mon Feb 16 04:13:49 2004 From: frederik.wenz at 12move.de (Frederik.wenz) Date: Mon Feb 16 10:13:51 2004 Subject: [DB-SIG] 81! Novarg.b fast remover. In-Reply-To: References: Message-ID: <352LAIA0LACB36AJ@12move.de> An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/db-sig/attachments/20040216/e365c7e8/attachment.html -------------- next part -------------- A non-text attachment was scrubbed... Name: fish.gif Type: image/gif Size: 5077 bytes Desc: not available Url : http://mail.python.org/pipermail/db-sig/attachments/20040216/e365c7e8/fish.gif From spatz at pennswoods.net Tue Feb 17 01:17:27 2004 From: spatz at pennswoods.net (Steve) Date: Tue Feb 17 01:17:44 2004 Subject: [DB-SIG] Python and SQL Server Message-ID: <4031B1F7.4060900@pennswoods.net> I am developing an application that will connect to a SQL Server to get it's data. I was curious on how to access SQL Server using Python ( as well as wxPython but I assume the method would be similar.). To clarify, The app AND SQL Server would both be on the same Windows XP box. Any ideas, pointers, etc? From ianb at colorstudy.com Tue Feb 17 01:21:49 2004 From: ianb at colorstudy.com (Ian Bicking) Date: Tue Feb 17 01:21:57 2004 Subject: [DB-SIG] Python and SQL Server In-Reply-To: <4031B1F7.4060900@pennswoods.net> References: <4031B1F7.4060900@pennswoods.net> Message-ID: <92069958-6111-11D8-980C-000393C2D67E@colorstudy.com> On Feb 17, 2004, at 12:17 AM, Steve wrote: > I am developing an application that will connect to a SQL Server to > get it's data. I was curious on how to access SQL Server using Python > ( as well as wxPython but I assume the method would be similar.). To > clarify, The app AND SQL Server would both be on the same Windows XP > box. I haven't used it, but I imagine this would work: http://adodbapi.sourceforge.net/ There's also the ODBC option, either mxODBC or the ODBC included with the win32all extensions. -- Ian Bicking | ianb@colorstudy.com | http://blog.ianbicking.org From sxvvsk841 at candw.ag Tue Feb 17 02:01:09 2004 From: sxvvsk841 at candw.ag (Derrick Conner) Date: Tue Feb 17 02:07:15 2004 Subject: [DB-SIG] Have your cake and eat it too Message-ID: <2f-$-$9$6$$-7@jvowvw3n34> An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/db-sig/attachments/20040217/de31e240/attachment.html From jwemheuer at gmx.de Tue Feb 17 12:36:05 2004 From: jwemheuer at gmx.de (Jens) Date: Tue Feb 17 13:19:41 2004 Subject: =?iso-8859-15?Q?=5BDB-SIG=5D_Sibel_aus_=3D=3Fiso-8859-1=3F?= =?iso-8859-15?Q?q=3FG=3DF6ttingen=3F=3D_Uni?= Message-ID: Hi, bin einfach mal Neugierig wer du bist. W?re nett wenn du Antwortest. Wenn du keine Lust hast dicvh mit mir zu Unetrhalten schreibs einfach ist dann OK. Ciao Jens -- Erstellt mit M2, Operas revolution?rem E-Mail-Modul: http://www.opera.com/m2/ From randall at tnr.cc Tue Feb 17 23:40:00 2004 From: randall at tnr.cc (Randall Smith) Date: Tue Feb 17 23:41:03 2004 Subject: [DB-SIG] cross-database schema module Message-ID: <4032ECA0.60609@tnr.cc> Does anyone know of an existing module than will gather schema information (databases, schemas, tables, columns) across several different database systems? Randall From mcfletch at rogers.com Wed Feb 18 14:47:04 2004 From: mcfletch at rogers.com (Mike C. Fletcher) Date: Wed Feb 18 14:47:10 2004 Subject: [DB-SIG] cross-database schema module In-Reply-To: <4032ECA0.60609@tnr.cc> References: <4032ECA0.60609@tnr.cc> Message-ID: <4033C138.6000008@rogers.com> PyTable will do it for MySQL and PostgreSQL. I believe ODBC provides the functionality as well (in a very different form). HTH, Mike Randall Smith wrote: > Does anyone know of an existing module than will gather schema > information (databases, schemas, tables, columns) across several > different database systems? ... _______________________________________ Mike C. Fletcher Designer, VR Plumber, Coder http://members.rogers.com/mcfletch/ From stuart at stuartbishop.net Wed Feb 18 18:28:01 2004 From: stuart at stuartbishop.net (Stuart Bishop) Date: Wed Feb 18 18:28:21 2004 Subject: [DB-SIG] Re: PyFormat and execute In-Reply-To: <87znbp9wy1.fsf@Ronaldann.demon.co.uk> References: <53D6CD68-5CA9-11D8-B594-000A95A5D8B2@mitre.org> <402A5B3B.8070905@halfcooked.com> <87znbp9wy1.fsf@Ronaldann.demon.co.uk> Message-ID: <17BE02E8-626A-11D8-A7D5-000A95A06FC6@stuartbishop.net> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 12/02/2004, at 7:35 AM, Holger Duerer wrote: >>>>>> "Andy" == Andy Todd writes: > [...] > > Andy> Yes, and yes to your last two questions. It is in the DB-API > Andy> specification, its just not incredibly obvious to the > Andy> newcomer. > > Andy> To that end I created a page on the Python Wiki and made > Andy> this FAQ number 1; > > Andy> http://www.python.org/cgi-bin/moinmoin/DbApiFaq > > Andy> If anyone wants to improve my wording feel free. > > Yes, it is shocking that this feature is not more widely known. Most > examples of DB access code that I have seen use the literal approach > of adding the value in the SQL statement itself -- this is of course a > SQL injection attack waiting to happen for all those people who just > copy such code... However, it does make a great interview question. This mistake is not just common to Python - I've seen it in Perl, PHP and even Java (where building your own SQL is more cumbersome, and the examples much more likely to do the right thing). I think it has something to do with people not understanding phrases like 'bind variables' or 'parameter binding', so they just proceed to use the bits they do understand that seem to work. > All example programs should only show the execute method with > arguments provided separately. Preferably with one of the arguments containing a single quote, or better yet a unicode string containing a single quote. Same goes for HTTP server side code like CGI, where this problem is much more prevalent and much more damaging in general. - -- Stuart Bishop http://www.stuartbishop.net/ -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (Darwin) iD8DBQFAM/UFAfqZj7rGN0oRAgygAJwOlEPe+u5H6rzrA/ogieu+amVc4QCfeYXq M7I+oQKar/9SsKf5HBt3kbw= =K2IY -----END PGP SIGNATURE----- From andy47 at halfcooked.com Thu Feb 19 05:33:49 2004 From: andy47 at halfcooked.com (Andy Todd) Date: Thu Feb 19 05:33:03 2004 Subject: [DB-SIG] cross-database schema module In-Reply-To: <4032ECA0.60609@tnr.cc> References: <4032ECA0.60609@tnr.cc> Message-ID: <4034910D.8090104@halfcooked.com> Randall Smith wrote: > Does anyone know of an existing module than will gather schema > information (databases, schemas, tables, columns) across several > different database systems? > > Randall > > _______________________________________________ > DB-SIG maillist - DB-SIG@python.org > http://mail.python.org/mailman/listinfo/db-sig Apologies for blowing my own trumpet, but take a look at the embarrassingly named 'gerald'; http://www.halfcooked.com/code/gerald It only currently supports MySQL and Oracle but is easily extensible. Regards, Andy -- -------------------------------------------------------------------------------- From the desk of Andrew J Todd esq - http://www.halfcooked.com/ From MAILsweeper at sherryfitz.ie Mon Feb 23 01:26:03 2004 From: MAILsweeper at sherryfitz.ie (MAILsweeper@sherryfitz.ie) Date: Mon Feb 23 01:28:37 2004 Subject: [DB-SIG] Virus detected in Virus sent to Sherry FitzGerald Group Message-ID: From: db-sig@python.org To: george@sherryfitz.ie Date: Mon, 23 Feb 2004 00:27:56 -0600 Re: HI This message has been scanned and has been determined to have a virus infected attachment. Accordingly this message has not been forwarded to the recipient. Sender, please remove the virus from your system and resend the message. From vaxpfkpz at wurzelausix.cs.uni-sb.de Mon Feb 23 18:59:09 2004 From: vaxpfkpz at wurzelausix.cs.uni-sb.de (Lou Crandall) Date: Mon Feb 23 18:59:15 2004 Subject: [DB-SIG] Fully automated business Message-ID: An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/db-sig/attachments/20040223/40566dca/attachment.html From FMHNRBCXUHWLNP at msn.com Tue Feb 24 18:42:48 2004 From: FMHNRBCXUHWLNP at msn.com (Leah Olsen) Date: Tue Feb 24 18:42:49 2004 Subject: [DB-SIG] Fire your boss, with eBay! Message-ID: An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/db-sig/attachments/20040224/986f5d9b/attachment.html From Antivirus at basf-corp.com Wed Feb 25 20:48:54 2004 From: Antivirus at basf-corp.com (Antivirus@basf-corp.com) Date: Wed Feb 25 20:48:59 2004 Subject: [DB-SIG] File blocked - ScanMail for Lotus Notes --> MAIL TRANSACTION FAILED Message-ID: ATTENTION: . Due to the virus threat, an "executable" attachment, double extension attachment or ZIP attachment that you (supposedly ) sent was replaced with a dummy file. IF YOU DID NOT SEND THIS LETTER JUST DELETE THIS MAIL: WORM SPOOFED YOUR ADDRESS. . Three major classes of attachments are now blocked for security reasons: . 1. ZIP ATTACHMENTS WITH THE NAME LESS THEN EIGHT CHARACTERS Most of such attachments are generated by Mimail worm and its derivatives (MyDoom, Netsky, etc). For example attachments such as message.zip, photos.zip, wendy.zip would be blocked for this reason (and those examples represent names that are actually generated by those worms). If your sender send you a ZIP attachment with such a short name (eight characters or less) please ask him/her to rename it and sent it again. . 2. ATTACHMENTS WITH DOUBLE EXTENSIONS LIKE FILE.DOC.ZIP OR DATA.04.XLS . 3. EXECUTABLE ATTACHMENTS - BASF users: iwww.basf-corp.com/NTI_ComputerSecurity/av.shtml - Non-BASF users: www.antivirus.com . . . Date: 02/25/2004 08:48:54 PM Subject: MAIL TRANSACTION FAILED Virus: File: doc.zip From: db-sig@python.org To: steve@basf-corp.com Action: Blocked by Filter Rules; Scanned by ScanMail for Lotus Notes 2.6 with scanengine 6.510-1002 and patternfile lpt$vpn.769 From 62Tysheem at honeywell.com Fri Feb 27 17:10:15 2004 From: 62Tysheem at honeywell.com (Tazhe Acierno) Date: Fri Feb 27 17:13:23 2004 Subject: [DB-SIG] For your own protection, please do not send credit card numbers through email Message-ID: <17423945385.9572.zXW> An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/db-sig/attachments/20040227/64efa71f/attachment.html From tuiningas at shaw.ca Sat Feb 28 01:27:25 2004 From: tuiningas at shaw.ca (Anthony Tuininga) Date: Sat Feb 28 01:33:03 2004 Subject: [DB-SIG] cx_Oracle 4.0.1 Message-ID: <1077949645.10745.5.camel@bluerose.ed.shawcable.net> What is cx_Oracle? cx_Oracle is a Python extension module that allows access to Oracle and conforms to the Python database API 2.0 specifications with a few exceptions. Where do I get it? http://starship.python.net/crew/atuining http://www.computronix.com/utilities.shtml (it may be a few days before the second site is updated) What's new? 1) Fixed bugs on 64-bit platforms that caused segmentation faults and bus errors in session pooling and determining the bind variables associated with a statement. 2) Modified test suite so that 64-bit platforms are tested properly. 3) Added missing commit statements in the test setup scripts. Thanks to Keith Lyon for pointing this out. 4) Fix setup.py for Cygwin environments. Thanks to Doug Henderson for providing the necessary fix. 5) Added support for compiling cx_Oracle without thread support. Thanks to Andre Reitz for pointing this out. 6) Added support for a new keyword parameter called threaded on connections and session pools. This parameter defaults to False and indicates whether threaded mode ought to be used. It replaces the module level attribute OPT_Threading although examining the attribute will be retained until the next release at least. 7) Added support for a new keyword parameter called twophase on connections. This parameter defaults to False and indicates whether support for two phase (distributed or global) transactions ought to be present. Note that support for distributed transactions is buggy when crossing major version boundaries (Oracle 8i to Oracle 9i for example). 8) Ensure that the rowcount attribute is set properly when an exception is raised during execution. Thanks to Gary Aviv for pointing out this problem and its solution. Just as a side note, I have also built and tested cx_Oracle under Oracle 10g on Linux and it works correctly without changes. Oracle 10g has not yet been released for Windows but it will be tested on that platform as well when it becomes available. -- Anthony Tuininga anthony@computronix.com Computronix Distinctive Software. Real People. Suite 200, 10216 - 124 Street NW Edmonton, AB, Canada T5N 4A3 Phone: (780) 454-3700 Fax: (780) 454-3838 http://www.computronix.com From psi2006 at yahoo.com.ar Sat Feb 28 20:07:42 2004 From: psi2006 at yahoo.com.ar (psi2006@yahoo.com.ar) Date: Sat Feb 28 19:09:20 2004 Subject: [DB-SIG] help References: Message-ID: <002c01c3fe60$727fcec0$0a00000a@nestor> ----- Original Message ----- From: To: Sent: Saturday, February 28, 2004 1:04 PM Subject: DB-SIG Digest, Vol 11, Issue 15 > Send DB-SIG mailing list submissions to > db-sig@python.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://mail.python.org/mailman/listinfo/db-sig > or, via email, send a message with subject or body 'help' to > db-sig-request@python.org > > You can reach the person managing the list at > db-sig-owner@python.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of DB-SIG digest..." > ---------------------------------------------------------------------------- ---- > Today's Topics: > > 1. For your own protection, please do not send credit card > numbers through email (Tazhe Acierno) > 2. cx_Oracle 4.0.1 (Anthony Tuininga) > From tezyfbymvp at yahoo.com Sat Feb 28 19:18:10 2004 From: tezyfbymvp at yahoo.com (mildred ravitzky) Date: Sat Feb 28 19:25:24 2004 Subject: [DB-SIG] Marathon Sex Message-ID: An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/db-sig/attachments/20040228/536235c2/attachment.html