From msrisney@ingr.com Thu Jul 1 00:16:33 1999 From: msrisney@ingr.com (Risney, Marc S) Date: Wed, 30 Jun 1999 18:16:33 -0500 Subject: [DB-SIG] Databases chapter for Python on Windows book Message-ID: <0534AD5B0B58D21190B1080009B96E89022FA85F@HQ2> Andy, my ramblings... Access , 97 and 2000, please!!, if you are writing specifically for win32, IMHO, most users/readers will at some point, most likely will be asked to develop using MS Access , one thing that you may want to experiment with (and I am just peeling back the layers, with python and VB) is that the office 2000 object library includes MSDE (as well as Jet, and DAO), which is the same database engine used in SQLServer 7, essentially MS Access 2000 is SQLServer 7 , with a 5 user license. Also the format of the .mdb is different that preceding version (Access 97, and 2.0), but there is an option to save and .MDB file as an earlier version. working with Oracle, Python is indispensable when I create the load and control files, in conjunction with SQL Loader for data loading. my load files are essentially ASCII text files that range in size form 1 meg to 2 gigs in size, I have even built a Tk GUI for setting up my Control files, for loading objects I use Oracle Tools, I would love to use Python, but I haven't the time to mess with Digital Creations Oracle module That's a hint to Paul Everitt, I really would like instructions on how to build the binary, or get a binary of their DCOracle module for win32. Gadfly, This is Aaron Waters' "Electric LadyLand", I have turned on GIS departments in Reston, VA to Python via Gadfly, used primarily as casual notetaker application, the ability to move the datafiles from platform to platform (Sun Solaris to WInNT to VAX and back..) is exercised daily, as CAD digitizers analyze remote sensing data (ok..satellite images) take notes, writing to a Gadfly datafile, that eventual are migrated into an Oracle RDBMS. to quote a senior engineer: "I am amazed, a little RDBMS, that fits on a floppy, that writes data - cross platform, that can be redesigned using MS Notepad, why would I wate time with Java." this is a killer app, I have yet to see a Perl equivalent. please give it a sidebar, I'm hoping that Aaron rev's it this fall, and add an ODBC.dll or .pyd so that it can be accessed through ODBC on other applications on a win32 > -----Original Message----- > From: andy@robanal.demon.co.uk [SMTP:andy@robanal.demon.co.uk] > Sent: Wednesday, June 30, 1999 3:13 PM > To: db-sig@python.org > Subject: [DB-SIG] Databases chapter for Python on Windows book > > As some of you know, Mark Hammona dna I are putting the finishing > touches to "Python Programming for Win32", due from O'Reilly this > autumn. I'm doing the database chapter. I hope you'll forgive me for > asking for answers I could probably dig out with a lot of research, > but I have a load of other subjects to research too. > > The book needs to 'punch the right buttons' for corporate developers > and IT managers and I am pushing the ideas of data cleaning and > transformation scripts in Python. > > Q1. I know the ODBC API and the Python DB API provide support for > precompiled SQL statements. What I don't know is which databases and > drivers actually use these to get better performance. Can anyone help > out on this? > > Q2. MySQL has quite a following. Monty granted me a license on > Windows for the sake of the book and I'd like to say something about > it. Unfortunately I have not yet found a compelling reason to use it > for examples. Is there anything neat that MySQL, or the Python > interface to it, does that cannot be do with (say) SQL Anywhere, > which is just as cheap on Windows? > > Q3. We like to include 'case studies' of half a page to a page to ram > home the point that Python is in use in the real world. Does anyone > have any neat stories to tell or projects to boast about? > > Many thanks, > > Andy Robinson > > > _______________________________________________ > DB-SIG maillist - DB-SIG@python.org > http://www.python.org/mailman/listinfo/db-sig From lohrum@zib.de Thu Jul 1 09:27:25 1999 From: lohrum@zib.de (Stefan Lohrum) Date: Thu, 1 Jul 1999 10:27:25 +0200 (MET DST) Subject: [DB-SIG] Databases chapter for Python on Windows book Message-ID: <199907010827.KAA15116@softs11.zib.de> Hello Andy et al, > Q3. We like to include 'case studies' of half a page to a page to ram > home the point that Python is in use in the real world. Does anyone > have any neat stories to tell or projects to boast about? Maybe you're interested in Ariadne, a retrieval system, providing you interactively with up to date computer science information available via the World Wide Web. It is written in Python, based on Sybase resp. Oracle RDMS, running on Unix and NT as well. We developed Ariadne by MeDoc Project at FU Berlin in 1996 and since then it is running stable with very less admin cost. URL: http://ariadne.inf.fu-berlin.de:8000 Best regards, Stefan Lohrum +---------------------------------------------------------------+ | Stefan Lohrum | Takustrasse 7 | | Konrad-Zuse-Zentrum Berlin (ZIB) | D-14195 Berlin-Dahlem | | Scientific Information Systems | Germany | |- - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - -| | E-Mail: lohrum@zib.de | Phone: +49 (30) 841 85-197 | | WWW: http://www.zib.de/lohrum | FAX: +49 (30) 841 85-269 | +---------------------------------------------------------------+ From kvbalaji@wipsys.soft.net Thu Jul 1 15:03:17 1999 From: kvbalaji@wipsys.soft.net (Balaji Yogesh K V) Date: Thu, 01 Jul 1999 19:33:17 +0530 Subject: [DB-SIG] Help required. Message-ID: <377B7525.8827FF6C@wipsys.soft.net> Hi, I would like to connect to a table in an MS Access database.I want to use ODBC. The operating system is Win NT and I have python 1.5 pls help me as how should i proceed. Basically, i want to execute a sql statement through a cursor after establishing a connections. regards, bala -- __________________________ __ /|___ Two | | | | / | wrongs | Balaji Yogesh K.V. | _| |_ \ ___| won't | kvbalaji@wipsys.soft.net | \ / \| make a | Wipro Infotech,India. | \ / ___|\ right. | +91 80 5539134. ext:209 | \/ | \ /-------------------------/ | |___ / \ 3 lefts will. \ _/ |/ `-------------------------- From tjohnson@matnet.com Fri Jul 2 14:27:07 1999 From: tjohnson@matnet.com (Tim Johnson) Date: Fri, 02 Jul 1999 05:27:07 -0800 Subject: [DB-SIG] Re: MS-Access In-Reply-To: <199907020500.BAA28918@python.org> Message-ID: <3.0.6.32.19990702052707.00910dc0@pop.matnet.com> > I would like to connect to a table in an MS Access database.I want to >use ODBC. The operating system is Win NT and I have python 1.5 I have precisely the same needs. Currently am using C++ Builder to do same. From mal@lemburg.com Tue Jul 6 17:00:12 1999 From: mal@lemburg.com (M.-A. Lemburg) Date: Tue, 06 Jul 1999 18:00:12 +0200 Subject: [DB-SIG] Databases chapter for Python on Windows book References: <377c9493.1555726@post.demon.co.uk> Message-ID: <3782280C.7866F3A0@lemburg.com> Andy Robinson wrote: > > As some of you know, Mark Hammona dna I are putting the finishing > touches to "Python Programming for Win32", due from O'Reilly this > autumn. I'm doing the database chapter. I hope you'll forgive me for > asking for answers I could probably dig out with a lot of research, > but I have a load of other subjects to research too. > > The book needs to 'punch the right buttons' for corporate developers > and IT managers and I am pushing the ideas of data cleaning and > transformation scripts in Python. > > Q1. I know the ODBC API and the Python DB API provide support for > precompiled SQL statements. What I don't know is which databases and > drivers actually use these to get better performance. Can anyone help > out on this? mxODBC caches the last execute string on every cursor. If you do: stuff = 'select ... ' for i in range(10): cursor.execute(stuff,(i,)) ... mxODBC will prepare the statement once and then reuse it for all subsequent calls. Cheers, -- Marc-Andre Lemburg ______________________________________________________________________ Y2000: 178 days left Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ From mal@lemburg.com Tue Jul 6 17:06:11 1999 From: mal@lemburg.com (M.-A. Lemburg) Date: Tue, 06 Jul 1999 18:06:11 +0200 Subject: [DB-SIG] Help required. References: <377B7525.8827FF6C@wipsys.soft.net> Message-ID: <37822973.6695AED8@lemburg.com> Balaji Yogesh K V wrote: > > Hi, > I would like to connect to a table in an MS Access database.I want to > use ODBC. The operating system is Win NT and I have python 1.5 > > pls help me as how should i proceed. Basically, i want to execute a sql > statement through a cursor after establishing a connections. Have a look at the database topic guide on www.python.org. That should get you started. -- Marc-Andre Lemburg ______________________________________________________________________ Y2000: 178 days left Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ From mal@lemburg.com Tue Jul 6 17:18:55 1999 From: mal@lemburg.com (M.-A. Lemburg) Date: Tue, 06 Jul 1999 18:18:55 +0200 Subject: [DB-SIG] Re: MS-Access References: <3.0.6.32.19990702052707.00910dc0@pop.matnet.com> Message-ID: <37822C6F.4C75BEBA@lemburg.com> Tim Johnson wrote: > > > I would like to connect to a table in an MS Access database.I want to > >use ODBC. The operating system is Win NT and I have python 1.5 > I have precisely the same needs. Currently am using C++ > Builder to do same. The standard odbc module or mxODBC (available from my Python Pages) should do the trick. Tips and tricks are available on www.python.org. Just look for the database topic guide. Cheers, -- Marc-Andre Lemburg ______________________________________________________________________ Y2000: 178 days left Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ From deirdre@deirdre.net Wed Jul 7 13:42:45 1999 From: deirdre@deirdre.net (Deirdre Saoirse) Date: Wed, 7 Jul 1999 05:42:45 -0700 (PDT) Subject: [DB-SIG] Best format to store web data? In-Reply-To: Message-ID: On Tue, 29 Jun 1999, Deirdre Saoirse wrote: > > The object database used by Zope would be a good choice. You might also > > consider Zope itself. See www.zope.org. > > Even better, squishdot (http://members.tripod.com/~squishdot) is exactly > what you're looking for -- it generates a /. style "articles" page using > python, gadfly and zope. Squishdot is impressive! -- _Deirdre * http://www.linuxcabal.org * http://www.deirdre.net "I have a simple rule in life: If I don't understand something, it must be bad." & "If you want more than 4 gig of memory, get a *real* CPU." -- Linus Torvalds, speaking at BALUG (www.balug.org) From andy@robanal.demon.co.uk Tue Jul 13 01:08:51 1999 From: andy@robanal.demon.co.uk (Andy Robinson) Date: Tue, 13 Jul 1999 00:08:51 GMT Subject: [DB-SIG] Databases chapter for Python on Windows book In-Reply-To: <199907010827.KAA15116@softs11.zib.de> References: <199907010827.KAA15116@softs11.zib.de> Message-ID: <378e834e.7458925@post.demon.co.uk> Thanks very much for everyone's help and advice over the last 2 weeks - this has given me everything I need for the book. Regards, Andy Robinson From schneckener@lion-ag.de Thu Jul 15 17:27:30 1999 From: schneckener@lion-ag.de (Sebastian Schneckener) Date: Thu, 15 Jul 1999 18:27:30 +0200 Subject: [DB-SIG] DCOracle / BLOB Message-ID: <378E0BF2.DF1BB677@Lion-AG.de> Hello everybody I am trying to store images as BLOB in an oracle database using the DCOracle interface. I found out, that if I use a statement like: cursor.execute ("INSERT INTO images values (1,1,1,'X',:p1)",(image,)) the image has to be in a hex format. So far, so easy, but if the image is larger than 4000 byte, I get a problem: File "/software/pub_gen/lib/python1.5/site-packages/DCOracle/ociCurs.py", line 225, in execute if rc!=3129: self._error() File "/software/pub_gen/lib/python1.5/site-packages/DCOracle/ociCurs.py", line 81, in _error raise error, (rc, oci_.OracleErrorMessage(self._c.lda, rc)) oci.error: (1461, 'ORA-01461: can bind a LONG value only for insert into a LONG column\012') Neither I realy understand this nor I know a workaround. The column type in images is BLOB of course. Anybody any ideas? Thanks Sebastian From jim@digicool.com Thu Jul 15 19:11:05 1999 From: jim@digicool.com (Jim Fulton) Date: Thu, 15 Jul 1999 14:11:05 -0400 Subject: [DB-SIG] DCOracle / BLOB References: <378E0BF2.DF1BB677@Lion-AG.de> Message-ID: <378E2439.A030FAF0@digicool.com> Sebastian Schneckener wrote: > > Hello everybody > > I am trying to store images as BLOB in an oracle database using the DCOracle interface. > I found out, that if I use a statement like: > > cursor.execute ("INSERT INTO images values (1,1,1,'X',:p1)",(image,)) > > the image has to be in a hex format. > So far, so easy, but if the image is larger than 4000 byte, I get a problem: > > File "/software/pub_gen/lib/python1.5/site-packages/DCOracle/ociCurs.py", line 225, in execute > if rc!=3129: self._error() > File "/software/pub_gen/lib/python1.5/site-packages/DCOracle/ociCurs.py", line 81, in _error > raise error, (rc, oci_.OracleErrorMessage(self._c.lda, rc)) > oci.error: (1461, 'ORA-01461: can bind a LONG value only for insert into a LONG column\012') > > Neither I realy understand this nor I know a workaround. The column type in images is BLOB of course. > Anybody any ideas? You can't really insert BLOBS using SQL in Oracle. (Well, you can insert short Blobs with SQL, but you cant update the values with SQL.) You have to create blob objects. :( From the documentation for the 1.2.1 release: Oracle 8 Large Objects (LOBs) Limited support is provided for Oracle 8 large objects (LOBs). To get LOB support, you must link against Oracle 8 client libraries and make sure that the -DDCORACLE8 switch is supplied when the oci_ extension module is built. LOB Columns can be selected in SQL Select statements. The way LOB data is returned depends on which fetch routine is used. If fetchone is used, then LOB objects are returned. Lob objects support the following methods: length() -- Return the LOB length read([n,offset,csid,csfrm]) -- Read data from the lob (OCILobRead) Up to 'n' characters are read, starting at the given 'offset', where the offset of the first character is **1**, not **0**. If the argument 'n' is less than 1 or is ommitted, then all data from the offset to the end of the LOB is read. The arguments csid and csfrm are as described in the documentation for the OCILobRead function in Oracle OCI 8 documentation. write(data, [offset,csid,csfrm]) -- Write data to the lob (OCILobWrite) The data given by the string argument 'data' are written to the LOB starting at the given 'offset', where the offset of the first character is **1**, not **0**. The arguments csid and csfrm are as described in the documentation for the OCILobRead function in Oracle OCI 8 documentation. Note that to add or update LOB data, you can provide string input. To update LOB data, you can select the lob and use the write method. If fetchmany or fetchall are used, then lobs are converted to strings and returned. I think I've seen cheesy examples in the Oracle docs where they insert a blank string, then to a select, and then call write on the selected object to actually insert data. Jim -- Jim Fulton mailto:jim@digicool.com Python Powered! Technical Director (888) 344-4332 http://www.python.org Digital Creations http://www.digicool.com http://www.zope.org Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email address may not be added to any commercial mail list with out my permission. Violation of my privacy with advertising or SPAM will result in a suit for a MINIMUM of $500 damages/incident, $1500 for repeats. From gstein@lyra.org Thu Jul 15 19:19:43 1999 From: gstein@lyra.org (Greg Stein) Date: Thu, 15 Jul 1999 11:19:43 -0700 Subject: [DB-SIG] DCOracle / BLOB References: <378E0BF2.DF1BB677@Lion-AG.de> <378E2439.A030FAF0@digicool.com> Message-ID: <378E263F.42C4367D@lyra.org> Jim Fulton wrote: > > Sebastian Schneckener wrote: > > > > Hello everybody > > > > I am trying to store images as BLOB in an oracle database using the DCOracle interface. > > I found out, that if I use a statement like: > > > > cursor.execute ("INSERT INTO images values (1,1,1,'X',:p1)",(image,)) > > > > the image has to be in a hex format. > > So far, so easy, but if the image is larger than 4000 byte, I get a problem: > > > > File "/software/pub_gen/lib/python1.5/site-packages/DCOracle/ociCurs.py", line 225, in execute > > if rc!=3129: self._error() > > File "/software/pub_gen/lib/python1.5/site-packages/DCOracle/ociCurs.py", line 81, in _error > > raise error, (rc, oci_.OracleErrorMessage(self._c.lda, rc)) > > oci.error: (1461, 'ORA-01461: can bind a LONG value only for insert into a LONG column\012') > > > > Neither I realy understand this nor I know a workaround. The column type in images is BLOB of course. > > Anybody any ideas? > > You can't really insert BLOBS using SQL in Oracle. (Well, you can insert short > Blobs with SQL, but you cant update the values with SQL.) You have to create > blob objects. :( > > >From the documentation for the 1.2.1 release: > > Oracle 8 Large Objects (LOBs) > > Limited support is provided for Oracle 8 large objects (LOBs). > To get LOB support, you must link against Oracle 8 client > libraries and make sure that the -DDCORACLE8 switch is supplied > when the oci_ extension module is built. Euh... what happened to being able to use dbi.dbiRaw() to wrap a string and insert it that way? I used to insert LONG objects all the time this way, even really large ones. Are BLOBs a different beast? Cheers, -g -- Greg Stein, http://www.lyra.org/ From jim@digicool.com Thu Jul 15 19:41:06 1999 From: jim@digicool.com (Jim Fulton) Date: Thu, 15 Jul 1999 14:41:06 -0400 Subject: [DB-SIG] DCOracle / BLOB References: <378E0BF2.DF1BB677@Lion-AG.de> <378E2439.A030FAF0@digicool.com> <378E263F.42C4367D@lyra.org> Message-ID: <378E2B42.40F941E1@digicool.com> Greg Stein wrote: > > I used to insert LONG objects all the time this way, even really large > ones. Are BLOBs a different beast? Yes they are. There are Oracle 8 object things with mostly non-SQL interfaces. Jim -- Jim Fulton mailto:jim@digicool.com Python Powered! Technical Director (888) 344-4332 http://www.python.org Digital Creations http://www.digicool.com http://www.zope.org Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email address may not be added to any commercial mail list with out my permission. Violation of my privacy with advertising or SPAM will result in a suit for a MINIMUM of $500 damages/incident, $1500 for repeats. From mal@lemburg.com Fri Jul 16 09:11:35 1999 From: mal@lemburg.com (M.-A. Lemburg) Date: Fri, 16 Jul 1999 10:11:35 +0200 Subject: [DB-SIG] mxODBC and MS SQL Server Message-ID: <378EE937.5D0E5801@lemburg.com> Just thought, I'd inform you of an inconvenience that occurs when using mxODBC to access MS SQL Server. The ODBC driver of SQL Server does not LONG columns to appear anywhere but the end of a SELECT columns list, e.g. SELECT anInteger, aString, aLONG FROM ... will work, but SELECT aString, aLONG, anInteger FROM ... won't. For now the work-around is simple: always put LONG columns at the end of the SELECT column list. The next version of mxODBC will include a fix for this. BTW, using the EasySoft ODBC bridge, you can now even access MS SQL Server running on a WinNT from any Unix machine, e.g. your web-server or Python development machine. More infos on mxODBC and all of the above can be found at: http://starship.skyport.net/~lemburg/mxODBC.html Cheers, -- Marc-Andre Lemburg ______________________________________________________________________ Y2000: 168 days left Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ From adustman@comstar.net Tue Jul 20 04:51:34 1999 From: adustman@comstar.net (Andy Dustman) Date: Mon, 19 Jul 1999 23:51:34 -0400 (EDT) Subject: [DB-SIG] ANNOUNCING: MySQLdb-0.0.3 now available Message-ID: MySQLdb-0.0.3 has just been released. You'll find it at: http://starship.python.net/crew/adustman I ran this sucker for about three hours (140 CPU minutes) with two simultanous threads with no leakage evident. However, there's an outside chance it may leak with more threads (like 10 or so). For you Zope smokers, there is a patch to ZMySQLDA to make it work with MySQLdb instead of MySQLmodule-1.4. Does it work? Maybe yes, maybe no; read the patch and don't complain to me if you go up or down an octave. Keep in mind, it won't work at all without at least MySQL-3.22.19, and MySQLmodule-1.4 uses 3.21.x AFAIK. 3.22.25 seems okay, except some weirdness with TIME columns (not my fault). And you need Python 1.5.2, but you need that for Zope 2.0.0 anyway, so get it. If you're actually using this module for something, I'd like to hear about it. Here is the FAQ: Q: Why do I have problems importing (missing symbols)? A: Either you don't have Python 1.5.2 (missing PyLong_FromLongLong) or you are linking against a shared output version of the MySQL client library and it's not on your LD_LIBRARY_PATH. (That's really the only frequently asked question at this point.) -- andy dustman | programmer/analyst | comstar communications corporation telephone: 770.485.6025 / 706.549.7689 | icq: 32922760 | pgp: 0xc72f3f1d From michel@digicool.com Tue Jul 20 06:33:40 1999 From: michel@digicool.com (Michel Pelletier) Date: Tue, 20 Jul 1999 01:33:40 -0400 Subject: [DB-SIG] Re: [Zope] ANNOUNCING: MySQLdb-0.0.3 now available References: Message-ID: <37940A34.3A8698D8@digicool.com> Andy Dustman wrote: > > MySQLdb-0.0.3 has just been released. You'll find it at: > > http://starship.python.net/crew/adustman > > I ran this sucker for about three hours (140 CPU minutes) with two > simultanous threads with no leakage evident. However, there's an outside > chance it may leak with more threads (like 10 or so). > > For you Zope smokers, there is a patch to ZMySQLDA to make it work with > MySQLdb instead of MySQLmodule-1.4. Does it work? Maybe yes, maybe no; > read the patch and don't complain to me if you go up or down an octave. > Keep in mind, it won't work at all without at least MySQL-3.22.19, and > MySQLmodule-1.4 uses 3.21.x AFAIK. 3.22.25 seems okay, except some > weirdness with TIME columns (not my fault). And you need Python 1.5.2, but > you need that for Zope 2.0.0 anyway, so get it. > > If you're actually using this module for something, I'd like to hear about > it. > > Here is the FAQ: Q: Why do I have problems importing (missing symbols)? A: > Either you don't have Python 1.5.2 (missing PyLong_FromLongLong) or you > are linking against a shared output version of the MySQL client library > and it's not on your LD_LIBRARY_PATH. > > (That's really the only frequently asked question at this point.) > Out of curiosity, does it release the Python global interpreter lock during I/O operations with the database? This is something I'll be doing with the new Sybase DA and the possible DB2 one. We may want to trade notes. -Michel the too lazy to download the source and look for himself > -- > andy dustman | programmer/analyst | comstar communications corporation > telephone: 770.485.6025 / 706.549.7689 | icq: 32922760 | pgp: 0xc72f3f1d > > _______________________________________________ > Zope maillist - Zope@zope.org > http://www.zope.org/mailman/listinfo/zope > > (For developer-specific issues, use the companion list, > zope-dev@zope.org - http://www.zope.org/mailman/listinfo/zope-dev ) From adustman@comstar.net Tue Jul 20 06:42:27 1999 From: adustman@comstar.net (Andy Dustman) Date: Tue, 20 Jul 1999 01:42:27 -0400 (EDT) Subject: [DB-SIG] Re: [Zope] ANNOUNCING: MySQLdb-0.0.3 now available In-Reply-To: <37940A34.3A8698D8@digicool.com> Message-ID: On Tue, 20 Jul 1999, Michel Pelletier wrote: > Out of curiosity, does it release the Python global interpreter lock > during I/O operations with the database? Absolutely. That was one of the major motivations for writing it. > This is something I'll be > doing with the new Sybase DA and the possible DB2 one. We may want to > trade notes. It's pretty darn straight-forward. Got a section that could block? Stick Py_BEGIN_ALLOW_THREADS before and Py_END_ALLOW_THREADS after. Don't manipulate any Python objects within that region. It's pretty well documented. > -Michel the too lazy to download the source and look for himself -- andy dustman | programmer/analyst | comstar communications corporation telephone: 770.485.6025 / 706.549.7689 | icq: 32922760 | pgp: 0xc72f3f1d From mal@lemburg.com Tue Jul 20 09:18:50 1999 From: mal@lemburg.com (M.-A. Lemburg) Date: Tue, 20 Jul 1999 10:18:50 +0200 Subject: [DB-SIG] Need help building a Zope Adaptor References: <37940A34.3A8698D8@digicool.com> Message-ID: <379430EA.67613E49@lemburg.com> Hi everybody, I would like to start looking at building a Zope adaptor for mxODBC. Where can I find documentation about the API and features such an adaptor would have to provide ? About mxODBC: mxODBC is a portable stable Python-ODBC interface which adheres to the DB API in most details. The package is free for use in free Open Source products (such as Zope). More information is available on my Python Pages. PS: I hope zope@zope.org is the right place to post this... sorry, if it's not. Thanks in advance, -- Marc-Andre Lemburg ______________________________________________________________________ Y2000: 164 days left Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ From hannu@trust.ee Tue Jul 20 10:03:43 1999 From: hannu@trust.ee (Hannu Krosing) Date: Tue, 20 Jul 1999 12:03:43 +0300 Subject: [DB-SIG] Re: [Zope] Need help building a Zope Adaptor References: <37940A34.3A8698D8@digicool.com> <379430EA.67613E49@lemburg.com> Message-ID: <37943B6F.A9B68561@trust.ee> "M.-A. Lemburg" wrote: > > Hi everybody, > > I would like to start looking at building a Zope adaptor for > mxODBC. Thats great! > Where can I find documentation about the API and > features such an adaptor would have to provide ? You should probably start with the win32 ODBC adaptor from http://www.zope.org/Download/ZODBCDA Don't be scared by the verbage about it being a binary relese, it just means that sql.pyd is included, otherways it seems to be fairly standard ZopeDA > PS: I hope zope@zope.org is the right place to post this... sorry, > if it's not. Maybe zope-dev@zope.org would be better, but for me at least it's ok here too ------------ Hannu From bstec@rulespace.com Tue Jul 20 16:48:44 1999 From: bstec@rulespace.com (Brad Stec) Date: Tue, 20 Jul 1999 08:48:44 -0700 Subject: [DB-SIG] Sample Code of Python/MySQL Message-ID: <819A4520FB36D3118C930090278A088703E2E8@postal.rulespace.com> Does anyone have any good sample Python source-code describing interfacing with mySQL? I'm exploring use of Andy Dustman's MySQLdb module and could use some reference. I'm building up a MySQLdb API "cgi trainer" for my team with examples of how to exploit mySQL's basics through the module and could sure use some support. If all goes well and it passes inspection, I'll ask Andy if he'd like to include it with the module files. Thanks. Brad ---------------------------------------------------------------------------- ----- Bradley Stec, Webmaster, RuleSpace Inc. http://www.rulespace.com http://www.rulespacesuite.com http://www.webchaperone.com 208 SW Stark, 4th Floor, Portland, Oregon 503-417-2900 x116 As complexity rises, precise statements lose meaning and meaningful statements lose precision. Law of Incompatibility, Lotfi Zadeh From adustman@comstar.net Tue Jul 20 17:52:06 1999 From: adustman@comstar.net (Andy Dustman) Date: Tue, 20 Jul 1999 12:52:06 -0400 (EDT) Subject: [DB-SIG] Sample Code of Python/MySQL In-Reply-To: <819A4520FB36D3118C930090278A088703E2E8@postal.rulespace.com> Message-ID: On Tue, 20 Jul 1999, Brad Stec wrote: > Does anyone have any good sample Python source-code describing interfacing > with mySQL? > > I'm exploring use of Andy Dustman's MySQLdb module and could use some > reference. I'm building up a MySQLdb API "cgi trainer" for my team with > examples of how to exploit mySQL's basics through the module and could sure > use some support. The basics would just be whatever is in the DB API 2.0 spec over at www.python.org. Generally it's db=MySQL.connect(host='host',user='user',passwd='password',db='dbname') c=db.cursor() c.execute(query) l=c.fetchall() > If all goes well and it passes inspection, I'll ask Andy if he'd like to > include it with the module files. I'll take a look, sure. -- andy dustman | programmer/analyst | comstar communications corporation telephone: 770.485.6025 / 706.549.7689 | icq: 32922760 | pgp: 0xc72f3f1d From bstec@rulespace.com Tue Jul 20 18:18:11 1999 From: bstec@rulespace.com (Brad Stec) Date: Tue, 20 Jul 1999 10:18:11 -0700 Subject: [DB-SIG] Sample Code of Python/MySQL Message-ID: <819A4520FB36D3118C930090278A088703E2F2@postal.rulespace.com> I'm putting in some examples of the various SQL commands and ways to get the data. Its really for complete novices... like me. :) I decided that as I learn it I might as well document it. I'll send you what I get when I get it done. Thanks! Brad -----Original Message----- From: Andy Dustman [mailto:adustman@comstar.net] Sent: Tuesday, July 20, 1999 9:52 AM To: Brad Stec Cc: db-sig@python.org Subject: Re: [DB-SIG] Sample Code of Python/MySQL On Tue, 20 Jul 1999, Brad Stec wrote: > Does anyone have any good sample Python source-code describing interfacing > with mySQL? > > I'm exploring use of Andy Dustman's MySQLdb module and could use some > reference. I'm building up a MySQLdb API "cgi trainer" for my team with > examples of how to exploit mySQL's basics through the module and could sure > use some support. The basics would just be whatever is in the DB API 2.0 spec over at www.python.org. Generally it's db=MySQL.connect(host='host',user='user',passwd='password',db='dbname') c=db.cursor() c.execute(query) l=c.fetchall() > If all goes well and it passes inspection, I'll ask Andy if he'd like to > include it with the module files. I'll take a look, sure. -- andy dustman | programmer/analyst | comstar communications corporation telephone: 770.485.6025 / 706.549.7689 | icq: 32922760 | pgp: 0xc72f3f1d From mal@lemburg.com Wed Jul 21 08:55:03 1999 From: mal@lemburg.com (M.-A. Lemburg) Date: Wed, 21 Jul 1999 09:55:03 +0200 Subject: [DB-SIG] Sample Code of Python/MySQL References: <819A4520FB36D3118C930090278A088703E2F2@postal.rulespace.com> Message-ID: <37957CD7.FEC97CF1@lemburg.com> Brad Stec wrote: > > I'm putting in some examples of the various SQL commands and ways to get the > data. Its really for complete novices... like me. :) I decided that as I > learn it I might as well document it. > > I'll send you what I get when I get it done. Could you put the examples on web-pages ? That way Andrew could link to it from the database topics guide on www.python.org. Cheers, -- Marc-Andre Lemburg ______________________________________________________________________ Y2000: 163 days left Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ From bstec@rulespace.com Wed Jul 21 17:28:54 1999 From: bstec@rulespace.com (Brad Stec) Date: Wed, 21 Jul 1999 09:28:54 -0700 Subject: [DB-SIG] Sample Code of Python/MySQL Message-ID: <819A4520FB36D3118C930090278A088703E35F@postal.rulespace.com> I'll see what I can do. Brad -----Original Message----- From: M.-A. Lemburg [mailto:mal@lemburg.com] Sent: Wednesday, July 21, 1999 12:55 AM To: Brad Stec Cc: db-sig@python.org Subject: Re: [DB-SIG] Sample Code of Python/MySQL Brad Stec wrote: > > I'm putting in some examples of the various SQL commands and ways to get the > data. Its really for complete novices... like me. :) I decided that as I > learn it I might as well document it. > > I'll send you what I get when I get it done. Could you put the examples on web-pages ? That way Andrew could link to it from the database topics guide on www.python.org. Cheers, -- Marc-Andre Lemburg ______________________________________________________________________ Y2000: 163 days left Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ From adustman@comstar.net Wed Jul 21 18:47:50 1999 From: adustman@comstar.net (Andy Dustman) Date: Wed, 21 Jul 1999 13:47:50 -0400 (EDT) Subject: [DB-SIG] Sample Code of Python/MySQL In-Reply-To: <37957CD7.FEC97CF1@lemburg.com> Message-ID: On Wed, 21 Jul 1999, M.-A. Lemburg wrote: > Brad Stec wrote: > > > > I'm putting in some examples of the various SQL commands and ways to get the > > data. Its really for complete novices... like me. :) I decided that as I > > learn it I might as well document it. > > > > I'll send you what I get when I get it done. > > Could you put the examples on web-pages ? That way Andrew could link > to it from the database topics guide on www.python.org. That really would be better. All the DB API database modules work basically the same. The two main exceptions to this are: A) the connect method (very database dependent) and B) formatting of parameters into query strings (same). For example, mxODBC (or perhaps, more accurately, ODBC) uses a question mark to indicate where a parameter should be substituted in, and MySQLdb uses %s, and some others use :1, :2, etc. -- andy dustman | programmer/analyst | comstar communications corporation telephone: 770.485.6025 / 706.549.7689 | icq: 32922760 | pgp: 0xc72f3f1d From tbryan@arlut.utexas.edu Fri Jul 23 03:55:47 1999 From: tbryan@arlut.utexas.edu (Thomas Bryan) Date: Thu, 22 Jul 1999 21:55:47 -0500 (CDT) Subject: [DB-SIG] Sample Code of Python/MySQL In-Reply-To: <819A4520FB36D3118C930090278A088703E35F@postal.rulespace.com> Message-ID: On Wed, 21 Jul 1999, Brad Stec wrote: > I'll see what I can do. > > -----Original Message----- > Brad Stec wrote: > > > > I'm putting in some examples of the various SQL commands and ways to get > > Could you put the examples on web-pages ? That way Andrew could link > to it from the database topics guide on www.python.org. If you don't have a place, I'd be happy to lend you a page on my Starship web pages. Of course, the better alternative would be for you to join the PSA and get your own Starship page. :) It's only $50/year, but the membership year starts on October 1. Thus, I could host it for a while if you want to hold off until then to join. ---Tom ------------------------------------------- Tom Bryan Applied Research Laboratories University of Texas at Austin From andy@robanal.demon.co.uk Mon Jul 26 14:52:18 1999 From: andy@robanal.demon.co.uk (=?iso-8859-1?q?Andy=20Robinson?=) Date: Mon, 26 Jul 1999 09:52:18 -0400 (EDT) Subject: [DB-SIG] Syntax for dates/times in prepared statements Message-ID: <19990726135218.11081.rocketmail@web608.mail.yahoo.com> Still at work on the database chapter for PPW32 - I'm doing some benchmarking on prepared vs. literal statements. I'd like to include dates and times in the parameter list and cannot find a syntax to let me do it. Any help gratefully received as failure to solve this kind of weakens my hymns of praise to mxDateTime! Currently using Sybase SQL Anywhere with their provided ODBC driver; mxODBC.Windows; and mxDateTime. cursor.execute("""INSERT INTO analysis (id, when, what, howmuch) VALUES (?,?,?,?)""", (id,when,what,howmuch)) fails however I represent the date-time in 'when'. Sybase complains about the SQL syntax. I've tried strings in many formats, numbers, and raw mxDateTime objects (I hoped the latter was the intention...) Without the "when" column, it all works beautifully and runs 60% faster with prepared statements. I also tried other column names. Also embedding dates in literal SQL statements is no problem. If this is a database-specific problem, can someone give me an example of a database it does work with, and what syntax they use? Many thanks, Andy Robinson === Andy Robinson Robinson Analytics Ltd. ------------------ My opinions are the official policy of Robinson Analytics Ltd. They just vary from day to day. _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com From mal@lemburg.com Mon Jul 26 16:36:07 1999 From: mal@lemburg.com (M.-A. Lemburg) Date: Mon, 26 Jul 1999 17:36:07 +0200 Subject: [DB-SIG] Syntax for dates/times in prepared statements References: <19990726135218.11081.rocketmail@web608.mail.yahoo.com> Message-ID: <379C8067.4639BA73@lemburg.com> Andy Robinson wrote: > > Still at work on the database chapter for PPW32 - I'm > doing some benchmarking on prepared vs. literal > statements. I'd like to include dates and times in > the parameter list and cannot find a syntax to let me > do it. Any help gratefully received as failure to > solve this kind of weakens my hymns of praise to > mxDateTime! > > Currently using Sybase SQL Anywhere with their > provided ODBC driver; mxODBC.Windows; and mxDateTime. > > cursor.execute("""INSERT INTO analysis > (id, when, what, howmuch) > VALUES (?,?,?,?)""", (id,when,what,howmuch)) > > fails however I represent the date-time in 'when'. > Sybase complains about the SQL syntax. I've tried > strings in many formats, numbers, and raw mxDateTime > objects (I hoped the latter was the intention...) That's how it's supposed to work... but date/time values are always "something special" because databases tend to be somewhat picky about what the format should look like. To help, I need more information though: the row description and the debugging output when executing the above statement. To get the debug output written to a file, please run Python in debug mode, i.e. 'python -d'. mxODBC should then write a file mxODBC.log which contains plenty of information about the dialog with the ODBC driver. Also, the output of the script ODBC/Misc/test.py would probably give some more insights. FYI, the latest pre-release is available at: http://starship.skyport.net/~lemburg/mxODBC-pre1.2.0.zip > Without the "when" column, it all works beautifully > and runs 60% faster with prepared statements. I also > tried other column names. Also embedding dates in > literal SQL statements is no problem. > > If this is a database-specific problem, can someone > give me an example of a database it does work with, > and what syntax they use? BTW, could be that the database doesn't like the order of the columns... some drivers want all things they consider special at the end of the list. -- Marc-Andre Lemburg ______________________________________________________________________ Y2000: 158 days left Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ From adustman@comstar.net Mon Jul 26 16:57:00 1999 From: adustman@comstar.net (Andy Dustman) Date: Mon, 26 Jul 1999 11:57:00 -0400 (EDT) Subject: [DB-SIG] Syntax for dates/times in prepared statements In-Reply-To: <19990726135218.11081.rocketmail@web608.mail.yahoo.com> Message-ID: On Mon, 26 Jul 1999, [iso-8859-1] Andy Robinson wrote: > Still at work on the database chapter for PPW32 - I'm > doing some benchmarking on prepared vs. literal > statements. I'd like to include dates and times in > the parameter list and cannot find a syntax to let me > do it. Any help gratefully received as failure to > solve this kind of weakens my hymns of praise to > mxDateTime! > > Currently using Sybase SQL Anywhere with their > provided ODBC driver; mxODBC.Windows; and mxDateTime. > > cursor.execute("""INSERT INTO analysis > (id, when, what, howmuch) > VALUES (?,?,?,?)""", (id,when,what,howmuch)) > > fails however I represent the date-time in 'when'. > Sybase complains about the SQL syntax. I've tried > strings in many formats, numbers, and raw mxDateTime > objects (I hoped the latter was the intention...) > > Without the "when" column, it all works beautifully > and runs 60% faster with prepared statements. I also > tried other column names. Also embedding dates in > literal SQL statements is no problem. It seems DateTime objects SHOULD be fine for when, if you are using mxODBC. I assume WHEN is a DATETIME column? If so, then a string with the ISO format, i.e. '1999-07-27 13:24:53.003', should also be fine. But a syntax error, you say. Is it possible that "when" is a reserved word in Sybase? If so, you may be able to circumvent this with a literal column name, i.e.: > cursor.execute("""INSERT INTO analysis > (id, "when", what, howmuch) > VALUES (?,?,?,?)""", (id,when,what,howmuch)) I.e. normal SQL column names are not case-sensitive, but if you quote them using the double-quotes, they are interpreted literally. I forget the technical SQL term for this, but I'm pretty sure that's how it works. -- andy dustman | programmer/analyst | comstar communications corporation telephone: 770.485.6025 / 706.549.7689 | icq: 32922760 | pgp: 0xc72f3f1d From andy@robanal.demon.co.uk Mon Jul 26 20:42:03 1999 From: andy@robanal.demon.co.uk (Andy Robinson) Date: Mon, 26 Jul 1999 19:42:03 GMT Subject: [DB-SIG] Syntax for dates/times in prepared statements In-Reply-To: References: Message-ID: <37a0b8d9.2355456@post.demon.co.uk> On Mon, 26 Jul 1999 11:57:00 -0400 (EDT), you wrote: >But a syntax error, you say. Is it possible that "when" is a reserved word >in Sybase? If so, you may be able to circumvent this with a literal column >name, i.e.: > >> cursor.execute("""INSERT INTO analysis >> (id, "when", what, howmuch) >> VALUES (?,?,?,?)""", (id,when,what,howmuch)) > Bingo! My first attempt called it 'Date', which I ard realised was pretty stupid. My second try was "When", which is not listed anywhere in their language reference, but still reserved - they have a "whenever" which might explain it. Double quotes or a totally different name fix it. For the record, DateTime objects work fine in all positions, and can go down to 0.01 second resolution in a Sybase TIMESTAMP field. In a DATE field they get truncated to the nearest day, as expected. The test output is handy, too - though I won't bombard M-A with all 300k now it works. Thanks very much, everyone! - Andy From tbryan@arlut.utexas.edu Thu Jul 29 15:09:48 1999 From: tbryan@arlut.utexas.edu (Thomas Bryan) Date: Thu, 29 Jul 1999 09:09:48 -0500 (CDT) Subject: [DB-SIG] Announcement: DB-API code fragment library In-Reply-To: Message-ID: On Wed, 21 Jul 1999, Brad Stec wrote: > I'll see what I can do. > > -----Original Message----- > Brad Stec wrote: > > > > I'm putting in some examples of the various SQL commands and ways to > > get > > Could you put the examples on web-pages ? That way Andrew could link > to it from the database topics guide on www.python.org. I don't know whether this idea will really take off, but I hope it does. I've set up a Python Database Code Fragment Library using the FAQ Wizard. http://starship.python.net/~tbryan/Database/Snippets/ My Goal: The Python DB-API Code Fragment Library will act as a repository for code fragments (short and long) showing how to use a DB-API compliant database extension. It will also act as a repository for code showing the quirks and exceptions when using specific databases and their extensions. This code library is maintained by its users. That is, if you want to add an example, please do! If you find and entry that no longer works, fix it. Organization: Section 1. general info about Python, the DB-API, Section 2. generic code for all DB-API compliant databases/modules; hopefully the largest section some day, code in this section should work with any Python interface that has fully implemented the spec Section 3+. specific info about using various databases from Python. The first entry is always general info about options for accessing the database from Python (ODBC, one or more extension modules, etc.). The following entries should show code that illustrates that database's quirks/deviations from the API or the quirks/deviations of specific extension modules for using that database. I decided to organize the sections by databaes instead of by python extension module. I thought that a DB user would find it easier to locate the information that he needs that way. I reserved section one for non-code stuff...just info about the code library and such. I also reserved the first entry of every section for some info about using a specific database with python (which modules are available, from where, etc.) Please add code, modify code, make the code library grow, send me suggestions (at tbryan@python.net), and generally just get excited about databases and Python for a few weeks. A few weeks of fervor followed by a long idle period where we all neglect the library still leaves a nice library for newbies to steal code from. :) The password for changes is: albatross Finally, thanks to Brad Stec for volunteering to create some sample code for MySQL in the first place and thanks to M.-A. Lemburg for suggesting that the code be posted to the web. I just thought that instead of creating a place for Brad to post his code, I'd solve the more general problem. :) And now for something completely different. ---Tom ------------------------------------------- Tom Bryan Applied Research Laboratories University of Texas at Austin From yura@vpcit.ru Fri Jul 30 11:47:15 1999 From: yura@vpcit.ru (Yury Don) Date: Fri, 30 Jul 1999 16:47:15 +0600 Subject: [DB-SIG] PyGreSQL module 2.4 Message-ID: <37A182B3.674E9E0C@vpcit.ru> Can somebody send me a compiled module _pgmodule.so version 2.4 for debian kernel 2.0.36 libc6-2.07u? Thank you in advance. Sincerely yours, Yury. don.web-page.net, ICQ 11831432