From wmonk@documentsolutions.com Mon Apr 3 04:48:35 2000 From: wmonk@documentsolutions.com (Wes Monk) Date: Sun, 2 Apr 2000 22:48:35 -0500 Subject: [DB-SIG] Remote Installation of Mysqldb Message-ID: <87043A502A47D2118D5300A0C9DD96DE4A4D09@OPUS> Does anybody have any advice how to remotely install the mysqldb module with only ftp and web (cgi-bin and normal page areas) access to a server? The server is at a hosting company with python and mysql installed. All access is non root (of course). Thanks in Advance wes monk From tbryan@starship.python.net Mon Apr 3 10:02:12 2000 From: tbryan@starship.python.net (Tom Bryan) Date: Mon, 3 Apr 2000 05:02:12 -0400 (EDT) Subject: [DB-SIG] Remote Installation of Mysqldb In-Reply-To: <87043A502A47D2118D5300A0C9DD96DE4A4D09@OPUS> Message-ID: On Sun, 2 Apr 2000, Wes Monk wrote: > Does anybody have any advice how to remotely install the mysqldb > module with only ftp and web (cgi-bin and normal page areas) access to > a server? Use os.popen or popen2 (I assume that the platform is Unix since they're running MySQL). You should be able to build the library extension and display the results of your build on your web browser. Do you know what OS they're running. If you're not sure how to do this, then you might want to take the thread to comp.lang.python or private e-mail because the thread could get long, but it won't have much relation to db-sig's charter (other than the fact that you're building Mysqldb). Basically, you'll be ftping Python scripts to your upload directory where you've already got the mysql tarball. You then make calls to gzip and tar to unpack the tarball, sending the output and error information to a file. Do whatever you normally have to do to publish the file you just produced, if anything. Point your web browser to that file. Look at the filenames that were just unpacked from the tarball. Point your web browser to the README/installation instructions. Read those to see how to build the extension. Then do the same thing that you did to When you're done with the build, you'll want to make the extension files readable by the nobody (or whatever account runs the http process) account but not writable by that account. You can delete the build tree except for the pieces that are actually used at run time (use os.unlink or shutil.rmtree). Don't forget to delete the tarball since it also takes up your (presumably limited) hard drive space. Note that compiling some packages requires a lot of space. You could conceivably overrun your space quota just trying to compile the library. If you run into trouble on the compile or aren't even sure how to run/use things like tar and gzip, then you're going to need a lot of guidance. Take the thread to comp.lang.python. Of course, the installation will be local to your directory, and you'll have to configure the installation that way. Have you checked to see whether any other user has already built Mysqldb? Maybe you could just use their .so file. :-) ---Tom From glinds@acxiom.com Mon Apr 3 14:10:07 2000 From: glinds@acxiom.com (glinds - Greg Lindstrom) Date: Mon, 3 Apr 2000 08:10:07 -0500 Subject: [DB-SIG] Persistent Storage of Objects Message-ID: Greetings- I have been writing an application for volunteer fire departments and am to the point of designing a database. I have read Joel Shprentz's paper Persistent Storage of Python Objects in Relational Databases (Proceedings of the 6th International Python Conference) and am wondering what is the "state of the art"? The program I am writing is OO, so this seems method seems ideal for my application. I have looked at Gadfly and mySQL; Gadfly wins because this must run on windows (no holy flames, please) and must be no cost to the departments. Are there examples out there (storage of objects), other than the one given in the back of the paper? Has this concept (saving objects) become the status quo? Thanks for you comments/help. =========================================================== Greg Lindstrom, ADN Development glinds@acxiom.com Acxiom Corporation Workspace: (501) 252-1626 Little Rock (Chenal Building) Admin: (501) 252-2093 Fax: (501) 252-4903 "..but I tell you it's not impossible, it simply has an infinite degree of difficulty" =========================================================== From petrilli@amber.org Mon Apr 3 14:55:31 2000 From: petrilli@amber.org (Christopher Petrilli) Date: Mon, 3 Apr 2000 09:55:31 -0400 Subject: [DB-SIG] Persistent Storage of Objects In-Reply-To: ; from glinds@acxiom.com on Mon, Apr 03, 2000 at 08:10:07AM -0500 References: Message-ID: <20000403095531.B14655@trump.amber.org> glinds - Greg Lindstrom [glinds@acxiom.com] wrote: > I have been writing an application for volunteer fire departments > and am to the point of designing a database. I have read Joel > Shprentz's paper Persistent Storage of Python Objects in Relational > Databases (Proceedings of the 6th International Python Conference) > and am wondering what is the "state of the art"? The program I am > writing is OO, so this seems method seems ideal for my application. it depends, of course, on your application. Relational "models" are always a shoe-horn fit for data, regardless of where it comes from. Their benefit is that thy have an abstract mathmatical basis which allows for interesting queries, etc. to be written with some adhoc nature. Having said this, sometimes object databases are better, all depending on what it is you're talking about doing. > I have looked at Gadfly and mySQL; Gadfly wins because this must run > on windows (no holy flames, please) and must be no cost to the > departments. Remember that Gadfly has no data types, and also needs ome C extensions to run at a reasonable rate. This however can be compiled in. Also, because it stores things in memory, you are constrained in teh size of database that you can work with. Having said that, I find it extreemly useful. > Are there examples out there (storage of objects), other than the > one given in the back of the paper? Has this concept (saving > objects) become the status quo? You might also look into the ZODBv3 that is under Zope, which is a pure transactional object database. There is no status quo in the persistence field, it's too wide open. Chris -- | Christopher Petrilli | petrilli@amber.org From akuchlin@mems-exchange.org Mon Apr 3 22:08:23 2000 From: akuchlin@mems-exchange.org (Andrew M. Kuchling) Date: Mon, 3 Apr 2000 17:08:23 -0400 (EDT) Subject: [DB-SIG] Persistent Storage of Objects In-Reply-To: <26453737@toto.iv> Message-ID: <14569.2119.167911.146321@amarok.cnri.reston.va.us> glinds - Greg Lindstrom writes: >Are there examples out there (storage of objects), other than the one >given in the back of the paper? Has this concept (saving objects) >become the status quo? It doesn't seem like it; Joel Shprentz's paper discusses mapping Python to a relational DB, and that seems to be about it. Recently I played around with the idea a bit before moving on to other things. I wonder if writing some standard framework for this sort of thing would be a useful task for the DB-SIG? (This is actually a good question; the DB-SIG is rather quiet these days, with only occasional specific questions about a particular DB module. Should the SIG be doing something such as an object->relation mapper? A ODMG binding for Python? Thoughts?) Chris Petrilli's pointer to the ZODB is also a good idea; while it's Python-specific, and hence not suitable if there's some external database that you must interface to. But it would be fine as an embedded database inside a standalone application. -- A.M. Kuchling http://starship.python.net/crew/amk/ Ah, yes. You must have grown on a particularly penetrating and incisive branch of the family tree. -- Barnabas to Delirium, in SANDMAN #48: "Brief Lives:8" From mal@lemburg.com Mon Apr 3 22:55:20 2000 From: mal@lemburg.com (M.-A. Lemburg) Date: Mon, 03 Apr 2000 23:55:20 +0200 Subject: [DB-SIG] Persistent Storage of Objects References: <14569.2119.167911.146321@amarok.cnri.reston.va.us> Message-ID: <38E91348.F2B1089E@lemburg.com> "Andrew M. Kuchling" wrote: > > glinds - Greg Lindstrom writes: > >Are there examples out there (storage of objects), other than the one > >given in the back of the paper? Has this concept (saving objects) > >become the status quo? > > It doesn't seem like it; Joel Shprentz's paper discusses mapping > Python to a relational DB, and that seems to be about it. Recently I > played around with the idea a bit before moving on to other things. > I wonder if writing some standard framework for this sort of thing > would be a useful task for the DB-SIG? I'm not sure whether a general framework is possible -- guess everybody has their own specific needs. The range of applications is huge: from simple dictionary like interfaces to tables to complete nested object hierarchies with auto-load and -store, version control and all the goodies in that bag. Plus maybe meta-information control to build search engines on top of the stored objects. > (This is actually a good question; the DB-SIG is rather quiet these > days, with only occasional specific questions about a particular DB > module. Should the SIG be doing something such as an object->relation > mapper? A ODMG binding for Python? Thoughts?) I'd rather like to see a DB API compatible JDBC interface... -- Marc-Andre Lemburg ______________________________________________________________________ Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ From akuchlin@mems-exchange.org Tue Apr 4 15:46:11 2000 From: akuchlin@mems-exchange.org (Andrew M. Kuchling) Date: Tue, 4 Apr 2000 10:46:11 -0400 (EDT) Subject: [DB-SIG] Persistent Storage of Objects In-Reply-To: <38E91348.F2B1089E@lemburg.com> References: <14569.2119.167911.146321@amarok.cnri.reston.va.us> <38E91348.F2B1089E@lemburg.com> Message-ID: <14570.51.90103.107848@amarok.cnri.reston.va.us> M.-A. Lemburg writes: >everybody has their own specific needs. The range of applications >is huge: from simple dictionary like interfaces to tables to >complete nested object hierarchies with auto-load and -store, >version control and all the goodies in that bag. Plus maybe >meta-information control to build search engines on top of the >stored objects. True, but maybe a useful middle ground could be implemented. Maybe something like Tangram (http://www.tangram-persistence.org/) -- you'd have a simple schema language for laying out classes, their attributes, and the relations between them, and then have code to store objects in a set of DB tables. >I'd rather like to see a DB API compatible JDBC interface... Is there anything about that problem that needs discussion, though, or is it a simple matter of programming? -- A.M. Kuchling http://starship.python.net/crew/amk/ Q. What does Kibo think of television? A. TV is evil and must be destroyed. A good way to do this is to watch your set until it burns out. -- The alt.religion.kibology FAQ From petrilli@amber.org Tue Apr 4 16:27:32 2000 From: petrilli@amber.org (Christopher Petrilli) Date: Tue, 4 Apr 2000 11:27:32 -0400 Subject: [DB-SIG] Persistent Storage of Objects In-Reply-To: <14570.51.90103.107848@amarok.cnri.reston.va.us>; from akuchlin@mems-exchange.org on Tue, Apr 04, 2000 at 10:46:11AM -0400 References: <14569.2119.167911.146321@amarok.cnri.reston.va.us> <38E91348.F2B1089E@lemburg.com> <14570.51.90103.107848@amarok.cnri.reston.va.us> Message-ID: <20000404112731.A19102@trump.amber.org> Andrew M. Kuchling [akuchlin@mems-exchange.org] wrote: > M.-A. Lemburg writes: > >everybody has their own specific needs. The range of applications > >is huge: from simple dictionary like interfaces to tables to > >complete nested object hierarchies with auto-load and -store, > >version control and all the goodies in that bag. Plus maybe > >meta-information control to build search engines on top of the > >stored objects. > > True, but maybe a useful middle ground could be implemented. Maybe > something like Tangram (http://www.tangram-persistence.org/) -- you'd > have a simple schema language for laying out classes, their > attributes, and the relations between them, and then have code to > store objects in a set of DB tables. If you *really* want to do this with the right architecture, I would recommend you steep yourself in Enterprise Objects Framework (from Apple, formerly NeXT). This is *way* ahead of anyone else's implementation and is based on a lot of graph theory and faulting. For more information, you should read: http://developer.apple.com/techpubs/webobjects/webobjects.html This has information on all of the frameworks. I've started working on providing a UML model of them, but it's pretty extensive. Chris -- | Christopher Petrilli | petrilli@amber.org From mal@lemburg.com Tue Apr 4 17:27:09 2000 From: mal@lemburg.com (M.-A. Lemburg) Date: Tue, 04 Apr 2000 18:27:09 +0200 Subject: [DB-SIG] Persistent Storage of Objects References: <14569.2119.167911.146321@amarok.cnri.reston.va.us> <38E91348.F2B1089E@lemburg.com> <14570.51.90103.107848@amarok.cnri.reston.va.us> Message-ID: <38EA17DD.480C1F80@lemburg.com> "Andrew M. Kuchling" wrote: > > M.-A. Lemburg writes: > >everybody has their own specific needs. The range of applications > >is huge: from simple dictionary like interfaces to tables to > >complete nested object hierarchies with auto-load and -store, > >version control and all the goodies in that bag. Plus maybe > >meta-information control to build search engines on top of the > >stored objects. > > True, but maybe a useful middle ground could be implemented. Maybe > something like Tangram (http://www.tangram-persistence.org/) -- you'd > have a simple schema language for laying out classes, their > attributes, and the relations between them, and then have code to > store objects in a set of DB tables. Thanks for the pointer. > >I'd rather like to see a DB API compatible JDBC interface... > > Is there anything about that problem that needs discussion, though, or > is it a simple matter of programming? No, just some implementors with some time on their hands ;-) -- Marc-Andre Lemburg ______________________________________________________________________ Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ Return-Path: Delivered-To: db-sig@python.org Received: from mailhost.rz.uni-karlsruhe.de (mailhost.rz.uni-karlsruhe.de [129.13.64.98]) by dinsdale.python.org (Postfix) with ESMTP id EFE901CE71 for ; Thu, 6 Apr 2000 08:06:43 -0400 (EDT) Received: from ubkadec2 (ubkadec2.ubka.uni-karlsruhe.de [129.13.130.35]) by mailhost.rz.uni-karlsruhe.de with smtp (Exim 3.02 #1) id 12dB5w-0001W9-00; Thu, 06 Apr 2000 14:09:08 +0200 Received: from ubkaaix6.ubka.uni-karlsruhe.de (ubkaaix6) by ubkadec2 (5.65c8/IDA-1.4.4); Thu, 6 Apr 2000 14:09:06 +0200 Received: by ubkaaix6.ubka.uni-karlsruhe.de (5.65c8/IDA-1.4.4); Thu, 6 Apr 2000 14:09:05 +0200 Date: Thu, 6 Apr 2000 14:07:20 +0200 From: Guenter Radestock To: db-sig.python.org@ubka.uni-karlsruhe.de Message-Id: <20000406140720.A34704@ubkaaix6.ubka.uni-karlsruhe.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.95.5i Resent-From: guenter@ubka.uni-karlsruhe.de Resent-Date: Thu, 6 Apr 2000 14:09:05 +0200 Resent-To: db-sig@python.org Resent-Message-Id: Subject: [DB-SIG] DCOracle number handling still broken? Sender: db-sig-admin@python.org Errors-To: db-sig-admin@python.org X-BeenThere: db-sig@python.org X-Mailman-Version: 2.0beta2 Precedence: bulk List-Id: SIG on Python Tabular Databases Hello, I have used the now unsupported oracledb-0.1.3 in the past to create some statistics from a database with the commands: cursor.execute('select avg(something) from somewhere') text = 'blah %.2f blah' % cursor.fetchone() Some time last year I converted to DCOracle, version 1.2.1 and now I see this does not work anymore (doesn't give an error, either). Aparantly, DCOracle returns every number truncated to an integer (again: this would work better with the old old oracledb.) I found that where svrmgrl returns 1.30436094, DCOracle will return (1,) as a result to the same select. I have downloaded a newer version (DCOracle-1.3.0) some time ago but I am not sure if this is fixed. Compiling DCOracle for a specific Oracle under AIX (4.2.1, Oracle 7.3.4) is no simple thing and I only managed to get a working version after throwing out shared library support and creating a giant python executable with all oracle libs statically linked. Is there a workaround to this problem that does not require rebuilding Python? Is this problem known and fixed? I failed to build DCOracle as a shared module for AIX 4.2.1/Oracle 7.3.4 because some Oracle networking lib needed a very old TCL/TK lib and I did not have a shared version of this; has anybody done this successfully before? - Guenter -- Guenter Radestock, Universitaetsbibliothek Karlsruhe guenter@ubka.uni-karlsruhe.de http://www.ubka.uni-karlsruhe.de/~guenter From petrilli@amber.org Thu Apr 6 15:50:05 2000 From: petrilli@amber.org (Christopher Petrilli) Date: Thu, 6 Apr 2000 10:50:05 -0400 Subject: [DB-SIG] DCOracle number handling still broken? Message-ID: <20000406105005.B26075@trump.amber.org> Guenter Radestock [guenter@ubka.uni-karlsruhe.de] wrote: > Some time last year I converted to DCOracle, version 1.2.1 and now I see > this does not work anymore (doesn't give an error, either). Aparantly, > DCOracle returns every number truncated to an integer (again: this would > work better with the old old oracledb.) I found that where svrmgrl > returns 1.30436094, DCOracle will return (1,) as a result to the same > select. Um, can you provide some insight into your schema? We sniff at the data types returned by Oracle, and try to do the right thing. The general number type format is: NUMBER(p,s) where 'p' is the precision (total number of digits) and 's' is the scale (or number of digits to the right of the decimal). If 's' is *not* zero, then we return a floating point, otherwise we try and get Python int v. long right (basically if p > 9, then long). I wonder if you just are using the Oracleism of NUMBER by itself, which is hard to know what it will return. > I have downloaded a newer version (DCOracle-1.3.0) some time ago but I > am not sure if this is fixed. Compiling DCOracle for a specific Oracle > under AIX (4.2.1, Oracle 7.3.4) is no simple thing and I only managed to > get a working version after throwing out shared library support and > creating a giant python executable with all oracle libs statically > linked. Well, this is an Oracle issue, not a DCOracle issue. Oracle 8/8i run fine with shared libraries on: Linux, Solaris and HP-UX, we don't have an AIX box around here to test on, but I know that at some point in the past, shared library support on AIX w/python was not correct. Chris -- | Christopher Petrilli | petrilli@amber.org From guenter@ubka.uni-karlsruhe.de Thu Apr 6 16:07:08 2000 From: guenter@ubka.uni-karlsruhe.de (Guenter Radestock) Date: Thu, 6 Apr 2000 17:07:08 +0200 Subject: [DB-SIG] DCOracle number handling still broken? In-Reply-To: <20000406105005.B26075@trump.amber.org>; from Christopher Petrilli on Thu, Apr 06, 2000 at 10:50:05AM -0400 References: <20000406105005.B26075@trump.amber.org> Message-ID: <20000406170708.A34650@ubkaaix6.ubka.uni-karlsruhe.de> On Thu, Apr 06, 2000 at 10:50:05AM -0400, Christopher Petrilli wrote: > Guenter Radestock [guenter@ubka.uni-karlsruhe.de] wrote: > > > Some time last year I converted to DCOracle, version 1.2.1 and now I see > > this does not work anymore (doesn't give an error, either). Aparantly, > > DCOracle returns every number truncated to an integer (again: this would > > work better with the old old oracledb.) I found that where svrmgrl > > returns 1.30436094, DCOracle will return (1,) as a result to the same > > select. > > Um, can you provide some insight into your schema? We sniff at the > data types returned by Oracle, and try to do the right thing. The > general number type format is: > > NUMBER(p,s) > > where 'p' is the precision (total number of digits) and 's' is the > scale (or number of digits to the right of the decimal). If 's' is > *not* zero, then we return a floating point, otherwise we try and get > Python int v. long right (basically if p > 9, then long). > > I wonder if you just are using the Oracleism of NUMBER by itself, > which is hard to know what it will return. I do use the description "number" in my schema and I only store integer values in the database itself. Cursor.description after a select returns the tuple (('AVG(AUSGELIEFERT-ERZEUGT)', 'NUMBER', 40, 22, 0, 0, 1),) The problem must be with avg() here. I find the following: create table numtest (x number, y number(4), z number(4, 2)); insert into numtest values (1, 2, 3.4); insert into numtest values (5, 6, 7.8); >>> cu.execute('select * from numtest') >>> cu.fetchone() (1, 2, 3.4) cu.description (('X', 'NUMBER', 40, 22, 0, 0, 1), ('Y', 'NUMBER', 40, 22, 4, 0, 1), ('Z', 'NUMBER', 40, 22, 4, 2, 1)) >>> cu.execute('select avg(x), avg(y), avg(z) from numtest'); >>> cu.fetchone() (3, 4, 5) >>> cu.description (('AVG(X)', 'NUMBER', 40, 22, 0, 0, 1), ('AVG(Y)', 'NUMBER', 40, 22, 0, 0, 1), ('AVG(Z)', 'NUMBER', 40, 22, 0, 0, 1)) -- Guenter Radestock, Universitaetsbibliothek Karlsruhe guenter@ubka.uni-karlsruhe.de http://www.ubka.uni-karlsruhe.de/~guenter From petrilli@amber.org Thu Apr 6 16:24:47 2000 From: petrilli@amber.org (Christopher Petrilli) Date: Thu, 6 Apr 2000 11:24:47 -0400 Subject: [DB-SIG] DCOracle number handling still broken? In-Reply-To: <20000406170708.A34650@ubkaaix6.ubka.uni-karlsruhe.de>; from guenter@ubka.uni-karlsruhe.de on Thu, Apr 06, 2000 at 05:07:08PM +0200 References: <20000406105005.B26075@trump.amber.org> <20000406170708.A34650@ubkaaix6.ubka.uni-karlsruhe.de> Message-ID: <20000406112447.D26075@trump.amber.org> Guenter Radestock [guenter@ubka.uni-karlsruhe.de] wrote: > On Thu, Apr 06, 2000 at 10:50:05AM -0400, Christopher Petrilli wrote: > I do use the description "number" in my schema and I only store integer > values in the database itself. Cursor.description after a select > returns the tuple (('AVG(AUSGELIEFERT-ERZEUGT)', 'NUMBER', 40, 22, 0, 0, > 1),) The problem must be with avg() here. I find the following: So long as we're clear, NUMBER by itself creates a floating-point with a precision of 38. Scale is not relevent. These should be handled correctly, though I don't know if they've been tested recently. > create table numtest (x number, y number(4), z number(4, 2)); OK, so we have a floating point, and a 4 digit int, and 4, 2 fixed precision. > insert into numtest values (1, 2, 3.4); > insert into numtest values (5, 6, 7.8); > > >>> cu.execute('select * from numtest') > >>> cu.fetchone() > (1, 2, 3.4) > cu.description > (('X', 'NUMBER', 40, 22, 0, 0, 1), ('Y', 'NUMBER', 40, 22, 4, 0, 1), > ('Z', 'NUMBER', 40, 22, 4, 2, 1)) INTERESTING, it's returning (0,0) as the (p,s) when you use the NUMBER by itself. This is why we're truncating it to an integer. Our code does the following est: if scale: turn it into a floating point elif prec < 10: turn it into a integer elif: turn it into a long We're turning it into an integer, whic his 'correct' except that Oracle is really giving us something bogus back :-) If you'd like, try modifying the code around line 161 of ociCurs.py, where it says: if scale: change that to be: if scale or ((not scale) and (not prec)): That should catch it :-) > >>> cu.execute('select avg(x), avg(y), avg(z) from numtest'); > >>> cu.fetchone() > (3, 4, 5) > >>> cu.description > (('AVG(X)', 'NUMBER', 40, 22, 0, 0, 1), ('AVG(Y)', 'NUMBER', 40, 22, 0, > 0, 1), ('AVG(Z)', 'NUMBER', 40, 22, 0, 0, 1)) This should be fixed as well :-) Chris -- | Christopher Petrilli | petrilli@amber.org From jmcgraw" Hello all, I'm new to both Python and ODBC so please forgive my ignorance... I've developed a small application on NT with Gadfly, but am in serious need for speed. I'm considering using MySQL, but am baffled as to what exactly I need to do to connect to MySQL from Python. I've downloaded/installed MyODBC, and I noticed that my Python/Win32 installation has an ODBC module...what next? Thank you, Joel From mal@lemburg.com Fri Apr 7 11:22:00 2000 From: mal@lemburg.com (M.-A. Lemburg) Date: Fri, 07 Apr 2000 12:22:00 +0200 Subject: [DB-SIG] Newbie ODBC question References: <006401bf9ff4$da734fd0$1400000a@jmcgraw.databill.com> Message-ID: <38EDB6C8.9B9FF786@lemburg.com> jmcgraw wrote: > > Hello all, > > I'm new to both Python and ODBC so please forgive my ignorance... > > I've developed a small application on NT with Gadfly, but am in serious need > for speed. >From what I have heard, Gadfly already provides pretty good performance... > I'm considering using MySQL, but > am baffled as to what exactly I need to do to connect to MySQL from Python. > I've downloaded/installed MyODBC, and I noticed that my Python/Win32 > installation has an ODBC module...what next? Install the Win32 MyODBC driver, add a data source in the Windows ODBC manager (ODBC Sources in the System folder) and then connect to it via e.g. the odbc module by giving the data source name as first argument, user id and password as second and third argument. If the win32all odbc module doesn't work out for, try mxODBC from my Python Pages. -- Marc-Andre Lemburg ______________________________________________________________________ Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ From michael.guidry@trigenttech.com Fri Apr 7 20:34:58 2000 From: michael.guidry@trigenttech.com (Michael Guidry) Date: Fri, 7 Apr 2000 14:34:58 -0500 Subject: [DB-SIG] fetchall() problem Message-ID: Why doesn't this cursor.fetchall() work? >>> import ODBC.Windows >>> conn = ODBC.Windows.Connect('FL_BS') >>> cursor = conn.cursor() >>> cursor.execute('SELECT AMTYP, AMLDS, AMDES FROM ATYMAST') >>> from pprint import pprint >>> pprint(cursor.description) (('AMTYP', -9, None, None, 2, 0, 1), ('AMLDS', -9, None, None, 30, 0, 1), ('AMDES', -9, None, None, 12, 0, 1)) >>> data = cursor.fetchall() Traceback (innermost last): File "", line 1, in ? InterfaceError: SQL type (code -9) not implemented >>> dir(cursor) ['arraysize', 'close', 'colcount', 'columnprivileges', 'columns', 'datetimeformat', 'description', 'execute', 'fetchall', 'fetchmany', 'fetchone', 'foreignkeys', 'getcursorname', 'gettypeinfo', 'primarykeys', 'procedurecolumns', 'procedures', 'rowcount', 'setcursorname', 'setinputsizes', 'setoutputsizes', 'specialcolumns', 'statistics', 'tableprivileges', 'tables'] Regards, Michael Guidry From mal@lemburg.com Fri Apr 7 22:07:54 2000 From: mal@lemburg.com (M.-A. Lemburg) Date: Fri, 07 Apr 2000 23:07:54 +0200 Subject: [DB-SIG] fetchall() problem References: Message-ID: <38EE4E2A.D953864@lemburg.com> Michael Guidry wrote: > > Why doesn't this cursor.fetchall() work? > > >>> import ODBC.Windows > >>> conn = ODBC.Windows.Connect('FL_BS') > >>> cursor = conn.cursor() > >>> cursor.execute('SELECT AMTYP, AMLDS, AMDES FROM ATYMAST') > >>> from pprint import pprint > >>> pprint(cursor.description) > (('AMTYP', -9, None, None, 2, 0, 1), > ('AMLDS', -9, None, None, 30, 0, 1), > ('AMDES', -9, None, None, 12, 0, 1)) > >>> data = cursor.fetchall() > Traceback (innermost last): > File "", line 1, in ? > InterfaceError: SQL type (code -9) not implemented Because SQL type -9 is Unicode and there currently is no Unicode support in mxODBC. Try converting the columns to string using SQL functions and then retry the fetch. > >>> dir(cursor) > ['arraysize', 'close', 'colcount', 'columnprivileges', 'columns', > 'datetimeformat', 'description', 'execute', 'fetchall', 'fetchmany', > 'fetchone', 'foreignkeys', 'getcursorname', 'gettypeinfo', 'primarykeys', > 'procedurecolumns', 'procedures', 'rowcount', 'setcursorname', > 'setinputsizes', 'setoutputsizes', 'specialcolumns', 'statistics', > 'tableprivileges', 'tables'] -- Marc-Andre Lemburg ______________________________________________________________________ Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ From tchur@bigpond.com Sat Apr 8 15:32:02 2000 From: tchur@bigpond.com (Tim Churches) Date: Sun, 09 Apr 2000 00:32:02 +1000 Subject: [DB-SIG] NumPy, Python DB-API and MySQL Message-ID: <38EF42E2.BD6946EF@bigpond.com> I've been experimenting with pulling quantitative data out of a MySQL table into NumPy arrays via Andy Dustman's excellent MySQLdb module and then calculating various statistics from the data using Gary Strangman's excellent stats.py functions, which when operating on NumPy arrays are lightning-fast. The problem is the speed with which data can be extracted from a column of a MySQL (or any other SQL database) query result set and stuffed into a NumPy array. This inevitably involves forming a Python list and then assigning that to a NumPy array. This is both slow and memory-hungry, especially with large datsets (I have een playing with a few million rows). I was wondering if it would be feasible to initially add a method to the _mysql class in the MySQLdb module which iterated through a result set using a C routine (rather than a Python routine) and stuffed the data directly into a NumPy array (or arrays - one for each column in the result set) in one fell swoop (or even iterating row-by-row but in C)? I suspect that such a facility would be much faster than having to move the data into NumPy via a standard Python list (or actually via tuples within a list, which i sthe way the Python DB-API returns results). If this direct MySQL-to-NumPy interface worked well, it might be desirable to add it to the Python DB-API specification for optional implementation in the other database modules which conform to the API. There are probably other extensions which would make the DB-API more useful for statistical applications, which tend to be set (column)-oriented rather than row-oriented - will post to the list as these occur to me. Cheers, Tim Churches PS I will be away for the next week so apologies in advance for not replying immediately to any follow-ups to this posting. TC From wongx2@hotmail.com Sun Apr 9 09:52:32 2000 From: wongx2@hotmail.com (Edward Wong) Date: Sun, 09 Apr 2000 01:52:32 PDT Subject: [DB-SIG] Oracle Connect example Message-ID: <20000409085232.862.qmail@hotmail.com> Hi, I'm brand new to Python, and I'm developing on Solaris 7. What module do I need to import to connect to an Oracle 8i database, and what would the connect string look like. As an example, I have a server named DevServer, user: Edward, pwd: mypassword. Can you show me how to connect, and call a stored procedure named "sp_MyProc(pInput, pOutput). Thanks, Edward ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com From tbryan@starship.python.net Sun Apr 9 13:07:39 2000 From: tbryan@starship.python.net (Tom Bryan) Date: Sun, 9 Apr 2000 08:07:39 -0400 (EDT) Subject: [DB-SIG] Oracle Connect example In-Reply-To: <20000409085232.862.qmail@hotmail.com> Message-ID: On Sun, 9 Apr 2000, Edward Wong wrote: > I'm brand new to Python, and I'm developing on Solaris 7. What module > do I need to import to connect to an Oracle 8i database You won't be able to connect until you or someone else has installed an extension module like DCOracle so that your Python can talk to Oracle. Go to www.python.org and look at the documentation under the db-sig (under the SIGs link) about databases and Python. (At one point, I thought that there was a nice databases HOWTO, but I can't find it anymore.) Then look at the database modules link from the db-sig pages, and get DCOracle or mxODBC (depending upon whether you want to work with ODBC). ---Tom From adustman@comstar.net Mon Apr 10 00:18:43 2000 From: adustman@comstar.net (Andy Dustman) Date: Sun, 9 Apr 2000 19:18:43 -0400 (EDT) Subject: [DB-SIG] Newbie ODBC question In-Reply-To: <006401bf9ff4$da734fd0$1400000a@jmcgraw.databill.com> Message-ID: On Thu, 6 Apr 2000, jmcgraw wrote: > Hello all, > > I'm new to both Python and ODBC so please forgive my ignorance... > > I've developed a small application on NT with Gadfly, but am in serious need > for speed. I'm considering using MySQL, but > am baffled as to what exactly I need to do to connect to MySQL from Python. > I've downloaded/installed MyODBC, and I noticed that my Python/Win32 > installation has an ODBC module...what next? MySQLdb-0.2.0 does work with Windows 95/98/NT, no ODBC required. It should be a lot faster than going through an intermediate ODB module (like MyODBC). http://starship.python.net/crew/adustman/MySQLdb.html Note: The Windows install routine (compile.py) is user-contributed. I can't answer any Windows-specific questions because my head might explode. -- andy dustman | programmer/analyst | comstar.net, inc. telephone: 770.485.6025 / 706.549.7689 | icq: 32922760 | pgp: 0xc72f3f1d "Therefore, sweet knights, if you may doubt your strength or courage, come no further, for death awaits you all, with nasty, big, pointy teeth!" From python-list@teleo.net Sun Apr 9 23:44:01 2000 From: python-list@teleo.net (Patrick Phalen) Date: Sun, 9 Apr 2000 15:44:01 -0700 Subject: [DB-SIG] Newbie ODBC question In-Reply-To: References: Message-ID: <00040915514005.00554@quadra.teleo.net> :: On Thu, 6 Apr 2000, jmcgraw wrote: :: > I've developed a small application on NT with Gadfly, but am in serious need :: > for speed. I'm considering using MySQL, but :: > am baffled as to what exactly I need to do to connect to MySQL from Python. :: > I've downloaded/installed MyODBC, and I noticed that my Python/Win32 :: > installation has an ODBC module...what next? If speed is the need, you might also look at Metakit (http://www.equi4.com). In certain situations, Metakit can beat all comers (but can, in others, be dog slow). Depends on your application. But since installation for Python is laughably simple, you can test it out without breaking a sweat. From adustman@comstar.net Mon Apr 10 17:02:27 2000 From: adustman@comstar.net (Andy Dustman) Date: Mon, 10 Apr 2000 12:02:27 -0400 (EDT) Subject: [DB-SIG] MySQLdb-0.2.0 out Message-ID: I released MySQLdb-0.2.0 over the weekend. http://starship.python.net/crew/adustman for more details. -- andy dustman | programmer/analyst | comstar.net, inc. telephone: 770.485.6025 / 706.549.7689 | icq: 32922760 | pgp: 0xc72f3f1d "Therefore, sweet knights, if you may doubt your strength or courage, come no further, for death awaits you all, with nasty, big, pointy teeth!" From adustman@comstar.net Mon Apr 10 17:27:03 2000 From: adustman@comstar.net (Andy Dustman) Date: Mon, 10 Apr 2000 12:27:03 -0400 (EDT) Subject: [DB-SIG] Re: NumPy, Python DB-API and MySQL In-Reply-To: <38EF42E2.BD6946EF@bigpond.com> Message-ID: On Sun, 9 Apr 2000, Tim Churches wrote: > I've been experimenting with pulling quantitative data out of a MySQL > table into NumPy arrays via Andy Dustman's excellent MySQLdb module and > then calculating various statistics from the data using Gary Strangman's > excellent stats.py functions, which when operating on NumPy arrays are > lightning-fast. > > The problem is the speed with which data can be extracted from a column > of a MySQL (or any other SQL database) query result set and stuffed into > a NumPy array. This inevitably involves forming a Python list and then > assigning that to a NumPy array. This is both slow and memory-hungry, > especially with large datsets (I have een playing with a few million > rows). > > I was wondering if it would be feasible to initially add a method to the > _mysql class in the MySQLdb module which iterated through a result set > using a C routine (rather than a Python routine) and stuffed the data > directly into a NumPy array (or arrays - one for each column in the > result set) in one fell swoop (or even iterating row-by-row but in C)? I > suspect that such a facility would be much faster than having to move > the data into NumPy via a standard Python list (or actually via tuples > within a list, which i sthe way the Python DB-API returns results). > > If this direct MySQL-to-NumPy interface worked well, it might be > desirable to add it to the Python DB-API specification for optional > implementation in the other database modules which conform to the API. > There are probably other extensions which would make the DB-API more > useful for statistical applications, which tend to be set > (column)-oriented rather than row-oriented - will post to the list as > these occur to me. It might be possible to do something like this. I would prefer that such a feature work as a seperate module (i.e. I don't think it is generally applicable to MySQLdb/_mysql). Or perhaps it could be a compile-time option for _mysql (-DUSE_NUMPY). The object that you want to mess with is the _mysql result object. It contains an attribute MYSQL_RES *result, which is a pointer to the actual MySQL structure. I don't remember if NumPy arrays are extensible or not, i.e. can rows be appended? That would affect the design. If they are not extensible, then you are probably limited to using mysql_store_result() (result set stored on the client side), as opposed to mysql_use_result() (result set stored on the server side). mysql_store_result is probably preferable in this case anyway, so extensibility doesn't matter, as we can find the size of the result set in advance with mysql_num_rows(). Then we know the full size of the array. However, with very large result sets, it may be necessary to use mysql_use_result(), in which case the array will need to be extended, possibly row-by-row. I could do this, but I need to know how to create and assign values to a NumPy array from within C. Or perhaps an initial (empty) array with the correct number of columns can be passed. I am pretty sure NumPy arrays look like sequences (of sequences), so assignment should not be a big problem. Easiest solution (for me, and puts least bloat in _mysql) would be for the user to pass in a NumPy array. Question: Would it be adequate to put all columns returned into the array? If label columns need to be returned, this could pose a problem. They may have to be returned as a separate query. Or else non-numeric columns would be excluded and returned in a list of tuples (this would be harder). I suspect the existing cursor.executemany() is capable of INSERTing and UPDATEing NumPy arrays. -- andy dustman | programmer/analyst | comstar.net, inc. telephone: 770.485.6025 / 706.549.7689 | icq: 32922760 | pgp: 0xc72f3f1d "Therefore, sweet knights, if you may doubt your strength or courage, come no further, for death awaits you all, with nasty, big, pointy teeth!" From Magnus Lycka Wed Apr 12 22:16:22 2000 From: Magnus Lycka (Magnus Lycka) Date: Wed, 12 Apr 2000 23:16:22 +0200 Subject: [DB-SIG] Python, DB2, Solaris and NT In-Reply-To: <00040915514005.00554@quadra.teleo.net> References: <00040915514005.00554@quadra.teleo.net> Message-ID: I have to admit (blushing) that while I've used SQL databases for a decade, and Python for several years, and even followed this mailing list for a couple of years, I have so far avoided using any database interface in Python, and instead post-processed text-files containing SQL output or done database access through os.popen etc. This works, but it's not as smooth as it could be... I thought it would be time to actually integrate Python and some SQL databases a little better. I'm currently working with DB2 in Solaris and NT. Unfortunately, there doesn't seem to be any DB2 dbi (at least not in the module list in the SIG web page or anywhere else where I looked...). As I'm currently reading 'Python Programming on Win32' (which I can happily recommend to anyone who works with a Windows or NT) I tried out the ODBC package in PythonWin. With some trial and error I (just) managed to log in with odbc.odbc('DBNAME/user/passwd') I'm _so_ happy :-) but a problem remains... How do I run this in our _real_ environment: Solaris. As far as I understand mxODBC works happily in Unix, but I don't think DB2 talks ODBC there. I understood that there is some kind of iODBC thingie that works under Unix, but I still don't grok it. How could that talk to the DB2 databases in our lovely Sun Enterprice 2000 Servers? Routing via my NT station that has a ODBC interface to the DB2 client, and then back to the Sun machine again? Somehow, that doesn't sound very efficient...or am I missing something (except a DB2 dbi ;-). Please, someone, write me a DB2 dbi at once! Sorry, I should go to sleep now, but anyway, if there are any other Pythonians with DB2 out there, I'd be thrilled to get tips about this. TIA, Magnus Magnus Lyckå, S/W Developer, Thinkware AB, www.thinkware.se/ magnus@thinkware.se, tel +46(0)70 5828065, fax +46(0)70 6128065 From petrilli@amber.org Wed Apr 12 22:49:23 2000 From: petrilli@amber.org (Christopher Petrilli) Date: Wed, 12 Apr 2000 17:49:23 -0400 Subject: [DB-SIG] Python, DB2, Solaris and NT In-Reply-To: ; from magnus@thinkware.se on Wed, Apr 12, 2000 at 11:16:22PM +0200 References: <00040915514005.00554@quadra.teleo.net> Message-ID: <20000412174923.A15376@trump.amber.org> Magnus Lycka [magnus@thinkware.se] wrote: > > As far as I understand mxODBC works happily in > Unix, but I don't think DB2 talks ODBC there. > I understood that there is some kind of iODBC > thingie that works under Unix, but I still don't > grok it. How could that talk to the DB2 databases > in our lovely Sun Enterprice 2000 Servers? Routing > via my NT station that has a ODBC interface to the > DB2 client, and then back to the Sun machine again? > Somehow, that doesn't sound very efficient...or am > I missing something (except a DB2 dbi ;-). Actually, the DB2 "API" is called CLI, and is the same basic API as ODbC, as they are derived from the sam standard (x/open CLI). I believe mxODBC support DB2 directly... you hould look :-) Chris -- | Christopher Petrilli | petrilli@amber.org From Magnus Lycka Wed Apr 12 23:00:22 2000 From: Magnus Lycka (Magnus Lycka) Date: Thu, 13 Apr 2000 00:00:22 +0200 Subject: [DB-SIG] Python, DB2, Solaris and NT In-Reply-To: <20000412174923.A15376@trump.amber.org> References: <00040915514005.00554@quadra.teleo.net> <20000412174923.A15376@trump.amber.org> Message-ID: Citerar Christopher Petrilli : > Actually, the DB2 "API" is called CLI, and is the same basic API as > ODbC, as they are derived from the sam standard (x/open CLI). I > believe mxODBC support DB2 directly... you hould look :-) Right, as I looked through the DB2 docs I found some stuff about ODBC under Unix so I guess there is hope. If this is basically the same i/f as the native DB2 API it might not even be slower? Anyway, I imagine I'll have to fiddle with odbc.ini files etc which is a complication since I'm neither sysadmin nor dba in this systems, and officially there is no such thing as Python in this house. As an external consultant it might not be good to be too creative. Anyway, concrete Python/DB2 experiences would be good---we really lack an automated way of doing system tests here (except for things that can be tested from the GUI), and my idea was to write Python scripts that would load databases, run test cases, inspect databases, evaluate and report... Maybe I'll have to try it out under Linux at home, and come back with a 'package'. That sound like much more work... Anyway...sleepy sleepy time in Europe now... Magnus Lyckå, S/W Developer, Thinkware AB, www.thinkware.se/ magnus@thinkware.se, tel +46(0)70 5828065, fax +46(0)70 6128065 From python-db-sig@teleo.net Wed Apr 12 21:53:53 2000 From: python-db-sig@teleo.net (Patrick Phalen) Date: Wed, 12 Apr 2000 13:53:53 -0700 Subject: [DB-SIG] Python, DB2, Solaris and NT In-Reply-To: References: <00040915514005.00554@quadra.teleo.net> Message-ID: <00041214134907.01669@quadra.teleo.net> [Magnus Lycka, on Wed, 12 Apr 2000] :: I have to admit (blushing) that while I've used SQL :: databases for a decade, and Python for several years, :: and even followed this mailing list for a couple of :: years, I have so far avoided using any database :: interface in Python, and instead post-processed :: text-files containing SQL output or done database :: access through os.popen etc. This works, but it's :: not as smooth as it could be... No need to blush! Noone is born knowing that stuff and I suspect some of us lurk here despite that fact that we prefer to while away our time as programmers, rather than as database administrators, no? You prompt another question from me, for the list. The Database Topics pages on www.python.org are well done and seem pretty up to date. But it seems like it would be useful, especially for pythoneers like me who don't live and breath that stuff, if there were a FAQ with a table of comparisons for all the databases for which Python has a module or API. This would help people trying to match their requirements to a Python-oriented solution without undue hunting. Specifically, it would be useful for first-timers to be able to do a quick scan on one page for such things as python dependancies, as well as factors like thread safety, bucket limits, and so forth. Does such a thing exist? If not, does anyone else agree it might help the Python cause? Would it be interesting to someone to create it, if they're knowledgable enough (I'm not)? If no one person has global knowledge, maybe it could be done as a Wiki, with people adding to it as needed. Just a thought ... From Magnus Lycka Thu Apr 13 09:17:26 2000 From: Magnus Lycka (Magnus Lycka) Date: Thu, 13 Apr 2000 10:17:26 +0200 Subject: [DB-SIG] Python, DB2, Solaris and NT In-Reply-To: <00041214134907.01669@quadra.teleo.net> References: <00040915514005.00554@quadra.teleo.net> <00041214134907.01669@quadra.teleo.net> Message-ID: Citerar Patrick Phalen : > a FAQ with a table of comparisons for all the databases for which > Python has a module or API. > > This would help people trying to match their requirements to a > Python-oriented solution without undue hunting. Sounds like a splendid idea. A Wiki or similar arrangement would obviously have the advantage that anyone can add whatever information that might be relevant, and I think we a civilized enough to do this in a reasonably controlled way. A collection of experiences would certainly be helpful, and if someone would do the effort of keeping some kind of table with side-by-side comparisions up-to-date, it would be even better. Magnus Lyckå, S/W Developer, Thinkware AB, www.thinkware.se/ magnus@thinkware.se, tel +46(0)70 5828065, fax +46(0)70 6128065 From mal@lemburg.com Thu Apr 13 10:12:41 2000 From: mal@lemburg.com (M.-A. Lemburg) Date: Thu, 13 Apr 2000 11:12:41 +0200 Subject: [DB-SIG] Python, DB2, Solaris and NT References: <00040915514005.00554@quadra.teleo.net> <00041214134907.01669@quadra.teleo.net> Message-ID: <38F58F89.F6D68CB9@lemburg.com> Magnus Lycka wrote: > > Citerar Patrick Phalen : > > > a FAQ with a table of comparisons for all the databases for which > > Python has a module or API. > > > > This would help people trying to match their requirements to a > > Python-oriented solution without undue hunting. > > Sounds like a splendid idea. A Wiki or similar > arrangement would obviously have the advantage > that anyone can add whatever information that > might be relevant, and I think we a civilized > enough to do this in a reasonably controlled way. > > A collection of experiences would certainly be > helpful, and if someone would do the effort of > keeping some kind of table with side-by-side > comparisions up-to-date, it would be even better. Perhaps someone could install the faqwiz.py on the DB SIG pages somewhere... this would work much like what you have in mind here -- provided people use it. -- Marc-Andre Lemburg ______________________________________________________________________ Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ From mal@lemburg.com Thu Apr 13 09:58:48 2000 From: mal@lemburg.com (M.-A. Lemburg) Date: Thu, 13 Apr 2000 10:58:48 +0200 Subject: [DB-SIG] Interest in a commercial Python database interface ? Message-ID: <38F58C48.63CB83A8@lemburg.com> Hi everybody, I wonder if there would be interest in a commercial database interface offering that allows you to connect to just about any database on many different platforms from Python using a DB API compatible interface. The idea is that mxODBC gets statically linked to one of the well- kown ODBC driver kits which then connects directly to all supported database backends. Setup would be simple, since the packages would ship as linked binaries. What's even better is that the price for the combined package would be lower than for both packages (mxODBC and the driver kit) together. Would this offer be well accepted ? What's your general attitude towards commercial offerings related to datbase interfacing in Python Space ? Thanks, -- Marc-Andre Lemburg ______________________________________________________________________ Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ From Magnus Lycka Thu Apr 13 16:28:02 2000 From: Magnus Lycka (Magnus Lycka) Date: Thu, 13 Apr 2000 17:28:02 +0200 Subject: [DB-SIG] Python, DB2, Solaris and NT In-Reply-To: <38F58F89.F6D68CB9@lemburg.com> References: <00040915514005.00554@quadra.teleo.net> <00041214134907.01669@quadra.teleo.net> <38F58F89.F6D68CB9@lemburg.com> Message-ID: Citerar "M.-A. Lemburg" : > Perhaps someone could install the faqwiz.py on the DB > SIG pages somewhere... this would work much like > what you have in mind here -- provided people use it. Actually, I think Wiki would be better. For those who haven't run in to this hypertext system before, I suggest you go to www.c2.com and take a look at "Portland Pattern Repository" or "Extreme Programming Roadmap". This is a Perl Wiki (I think), but there are also Python and Zope implementations. BTW, isn't there anyone actively working with DB2 and Python? /Magnus Magnus Lyckå, S/W Developer, Thinkware AB, www.thinkware.se/ magnus@thinkware.se, tel +46(0)70 5828065, fax +46(0)70 6128065 From sabren@manifestation.com Fri Apr 14 07:14:31 2000 From: sabren@manifestation.com (Michal Wallace (sabren)) Date: Fri, 14 Apr 2000 02:14:31 -0400 (EDT) Subject: [DB-SIG] db-api suggestions / zike data classes Message-ID: Hello Everybody :) I'm attempting to build an abstraction layer on top of the DB-API, that gives an object-oriented interface to individual records. Here's an example: ################################## import someDBAPIcompliantModule dbc = someDBAPIcompiantModule.connect("blah blah") import zdc.Record rec = zdc.Record(dbc, "myTable") rec.new() rec["name"] = "Michal" rec["age"] = 23 rec.save() rec.select(name="Fred") print "Fred is " + rec["age"] + "years old." # or: print "Fred is " + rec[1] + "years old." ################################## I've actually gotten most of it done (coming soon to sourceforge), but I've hit a couple snags because some things a scheme like this needs are missing from the (otherwise excellent) API. Anyway, I thought I'd bounce some ideas off the group: ----------------------- module - agnosticism ----------------------- First, if I'm just looking at some random connection object, and I use it to create a cursor object... How can I get the fieldtypes out of the description? The fieldtypes are arbitrary values that have to be compared against something back in the module's namespace... But since this is a random connection object, *I don't know what module to look in!!!* I'm testing with MySQLdb and ODBC.Windows. With MySQLdb, the task is simple: module = dbc.__class__.__module__ ... But with ODBC.Windows, and (I suspect) any other pure C/C++ module, there IS no .__class__ attribute. My workaround for ODBC.Windows was to create a wrapper class/module in python (which also brings ODBC.Windows quite a bit closer to the DB-API 2.0 standard)... But wouldn't it be nicer if either a) all Connection objects had to have a .__class__ , or: b) STRING, NUMBER, etc were part of the Connection class? ----------------------- autonumbers ----------------------- Suppose I have an autonumber / auto_increment / whatever field. I run an INSERT statement. How do I get the generated number? As far as I can tell, I have to use a module-specific function call. Wouldn't this be a fairly useful process to standardize? ----------------------- table names ----------------------- I personally don't have any particular need for this at the moment, but I'm sure it would be nice to have down the line: dbc.tables() to give a list of tables? Possibly even dbc.queries() or dbc.sprocs() for providers that had queries and stored procedures.. I'm guessing most modules have something like this already, but it's no fun without a standard. :) Anyway, I'm probably going to come up with a proposal for actual syntax and stuff, and make some wrapper modules just to get my classes working for now, but I'd really like to talk about the issues involved in updating the standard. (I'm willing to help code changes, too, btw) Cheers, - Michal ------------------------------------------------------------------------- http://www.manifestation.com/ http://www.linkwatcher.com/metalog/ ------------------------------------------------------------------------- From sabren@manifestation.com Fri Apr 14 08:02:54 2000 From: sabren@manifestation.com (Michal Wallace (sabren)) Date: Fri, 14 Apr 2000 03:02:54 -0400 (EDT) Subject: [DB-SIG] autonumbers w/ODBC? Message-ID: After further investigation: Is it even possible to get a generated Autonumbe field via ODBC? Microsoft Access seems to be able to do it well enough, but how do you do it with mxODBC? Cheers, - Michal ------------------------------------------------------------------------- http://www.manifestation.com/ http://www.linkwatcher.com/metalog/ ------------------------------------------------------------------------- From mal@lemburg.com Thu Apr 13 17:36:03 2000 From: mal@lemburg.com (M.-A. Lemburg) Date: Thu, 13 Apr 2000 18:36:03 +0200 Subject: [DB-SIG] Python, DB2, Solaris and NT References: <00040915514005.00554@quadra.teleo.net> <00041214134907.01669@quadra.teleo.net> <38F58F89.F6D68CB9@lemburg.com> Message-ID: <38F5F773.8016A21B@lemburg.com> Magnus Lycka wrote: > > BTW, isn't there anyone actively working with > DB2 and Python? Not actively, but I have tried to link mxODBC against its CLI libs. After some tweaking this does work. Still, I couldn't do any tests because I didn't have time to get IBM DB2 up and running on Linux (it is not exactly easy to install...). -- Marc-Andre Lemburg ______________________________________________________________________ Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ From mal@lemburg.com Fri Apr 14 08:45:06 2000 From: mal@lemburg.com (M.-A. Lemburg) Date: Fri, 14 Apr 2000 09:45:06 +0200 Subject: [DB-SIG] db-api suggestions / zike data classes References: Message-ID: <38F6CC81.A8ACEB4C@lemburg.com> "Michal Wallace (sabren)" wrote: > > I've actually gotten most of it done (coming soon to sourceforge), > but I've hit a couple snags because some things a scheme like this > needs are missing from the (otherwise excellent) API. Anyway, I > thought I'd bounce some ideas off the group: > > ----------------------- > module - agnosticism > ----------------------- > > First, if I'm just looking at some random connection object, and I > use it to create a cursor object... How can I get the fieldtypes out > of the description? The fieldtypes are arbitrary values that have to > be compared against something back in the module's namespace... But > since this is a random connection object, *I don't know what module > to look in!!!* > > I'm testing with MySQLdb and ODBC.Windows. With MySQLdb, the task > is simple: module = dbc.__class__.__module__ ... But with ODBC.Windows, > and (I suspect) any other pure C/C++ module, there IS no .__class__ > attribute. > > My workaround for ODBC.Windows was to create a wrapper class/module > in python (which also brings ODBC.Windows quite a bit closer to the > DB-API 2.0 standard)... But wouldn't it be nicer if either > > a) all Connection objects had to have a .__class__ , or: > b) STRING, NUMBER, etc were part of the Connection class? + c) all error objects That's the way I do it too. > ----------------------- > autonumbers > ----------------------- > > Suppose I have an autonumber / auto_increment / whatever field. I > run an INSERT statement. How do I get the generated number? As far > as I can tell, I have to use a module-specific function call. Wouldn't > this be a fairly useful process to standardize? Nope... various DBs have different concepts here, e.g. MySQL uses a hack to allow you to query the last inserted row in an INSERT statement. Other DBs have special column types/flags for this. Use max(id) and some algorithm instead (see my other post) -- its portable, works everywhere and usually does the trick pretty well. > ----------------------- > table names > ----------------------- > > I personally don't have any particular need for this at the moment, > but I'm sure it would be nice to have down the line: dbc.tables() to > give a list of tables? Possibly even dbc.queries() or dbc.sprocs() > for providers that had queries and stored procedures.. I'm guessing > most modules have something like this already, but it's no fun without > a standard. :) You mean catalog functions... uhm, we could simply use the ODBC standard names for these -- together with their return value strategy: as result set. But then, it would introduce extra complexity for *all* DB interfaces -- not sure this would be liked by the interface writers. Note that the ODBC catalog functions are nothing other than hidden DB-specific SQL statements which get executed... every DB interface could emulate these easily. > Anyway, I'm probably going to come up with a proposal for actual > syntax and stuff, and make some wrapper modules just to get my classes > working for now, but I'd really like to talk about the issues involved > in updating the standard. (I'm willing to help code changes, too, btw) -- Marc-Andre Lemburg ______________________________________________________________________ Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ From mal@lemburg.com Fri Apr 14 08:28:22 2000 From: mal@lemburg.com (M.-A. Lemburg) Date: Fri, 14 Apr 2000 09:28:22 +0200 Subject: [DB-SIG] autonumbers w/ODBC? References: Message-ID: <38F6C896.4D28B60B@lemburg.com> "Michal Wallace (sabren)" wrote: > > After further investigation: > > Is it even possible to get a generated Autonumbe field via ODBC? > Microsoft Access seems to be able to do it well enough, but how > do you do it with mxODBC? You don't generate autonumber fields, you declare them when you define the table schema. ODBC let's you do this just as all other DB API interfaces, but the syntax is of course DB specific and not all DBs support this feature. Its simplest to use max(id) during insert and then apply a few tries to catch simultaneous inserts in case they should happen. Works everywhere and doesn't need auto-increment columns. -- Marc-Andre Lemburg ______________________________________________________________________ Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ From sabren@manifestation.com Fri Apr 14 11:35:54 2000 From: sabren@manifestation.com (Michal Wallace (sabren)) Date: Fri, 14 Apr 2000 06:35:54 -0400 (EDT) Subject: [DB-SIG] autonumbers w/ODBC? In-Reply-To: <38F6C896.4D28B60B@lemburg.com> Message-ID: On Fri, 14 Apr 2000, M.-A. Lemburg wrote: > > Is it even possible to get a generated Autonumbe field via ODBC? > > Microsoft Access seems to be able to do it well enough, but how > > do you do it with mxODBC? > > You don't generate autonumber fields, you declare them when > you define the table schema. ODBC let's you do this just as > all other DB API interfaces, but the syntax is of course > DB specific and not all DBs support this feature. Whoops! I meant the generated value from an autonumber field. If I connect to SQL server or MySQL or whatever, I can add a record, and access knows/discovers the value of the new ID. > Its simplest to use max(id) during insert and then apply > a few tries to catch simultaneous inserts in case they > should happen. Works everywhere and doesn't need auto-increment > columns. how would you catch the simultaneous inserts? In any case, if for whatever reason the database designer has created an Autonumber field, I'd like my objects to handle it.. The max(ID) concept seems to have a lot of promise (thanks!) Let's say I insert "Homer Simpson" into a table with an autonumber field. I can get the max(ID) with a select statement, unless If someone inserts another record right after me. I can cover that easily enough with something like: SELECT MAX(ID), first, last from names WHERE first="Homer" and last="Simpson" GROUP BY ID, first, last .. But what if two people happen to insert Homer Simpson at the same time? I mean, if the other fields were always unique, I wouldn't necessarily need a primary key.. MySQL lets me skip all that and just call a function to get the last generated ID for my connection... I've seen Access get this result through ODBC, but I'm having a hard time figuring out how it works, Is there a function like this built into ODBC, or do you think they use a set of heuristics along the max(ID) lines..? Cheers, - Michal ------------------------------------------------------------------------- http://www.manifestation.com/ http://www.linkwatcher.com/metalog/ ------------------------------------------------------------------------- From Frank McGeough" Message-ID: <000c01bfa60b$1386ddc0$529b90d1@synchrologic.com> Getting autoincrement values is unfortunately very db specific. I think you will find most databases have some means to achieve this but they vary fairly wildly. There is no standard odbc means of retrieving this. Just to give you more to think about in your noble quest. For Microsoft SQL Server (I believe Sybase Sql Server works similarly) you can do : "SELECT @@identity" which returns the number last used by the current connection. This is probably similar to what you do in Access. For Oracle. There aren't autoincrement numbers. You can either use the ROWID as a unique number or do a select out of a special "sequence" table that returns a new number everytime. I believe this is the traditional method for generating these type of numbers for Oracle. ----- Original Message ----- From: Michal Wallace (sabren) To: Sent: Friday, April 14, 2000 6:35 AM Subject: Re: [DB-SIG] autonumbers w/ODBC? > On Fri, 14 Apr 2000, M.-A. Lemburg wrote: > > > > Is it even possible to get a generated Autonumbe field via ODBC? > > > Microsoft Access seems to be able to do it well enough, but how > > > do you do it with mxODBC? > > > > You don't generate autonumber fields, you declare them when > > you define the table schema. ODBC let's you do this just as > > all other DB API interfaces, but the syntax is of course > > DB specific and not all DBs support this feature. > > Whoops! I meant the generated value from an autonumber field. If I > connect to SQL server or MySQL or whatever, I can add a record, and > access knows/discovers the value of the new ID. > > > Its simplest to use max(id) during insert and then apply > > a few tries to catch simultaneous inserts in case they > > should happen. Works everywhere and doesn't need auto-increment > > columns. > > how would you catch the simultaneous inserts? > > In any case, if for whatever reason the database designer has created > an Autonumber field, I'd like my objects to handle it.. The max(ID) > concept seems to have a lot of promise (thanks!) > > Let's say I insert "Homer Simpson" into a table with an autonumber > field. I can get the max(ID) with a select statement, unless If > someone inserts another record right after me. I can cover that > easily enough with something like: > > SELECT MAX(ID), first, last from names > WHERE first="Homer" and last="Simpson" > GROUP BY ID, first, last > > .. But what if two people happen to insert Homer Simpson at the same > time? I mean, if the other fields were always unique, I wouldn't > necessarily need a primary key.. > > MySQL lets me skip all that and just call a function to get the last > generated ID for my connection... I've seen Access get this result > through ODBC, but I'm having a hard time figuring out how it works, > Is there a function like this built into ODBC, or do you think they > use a set of heuristics along the max(ID) lines..? > > Cheers, > > - Michal > ------------------------------------------------------------------------- > http://www.manifestation.com/ http://www.linkwatcher.com/metalog/ > ------------------------------------------------------------------------- > > > _______________________________________________ > DB-SIG maillist - DB-SIG@python.org > http://www.python.org/mailman/listinfo/db-sig From mal@lemburg.com Fri Apr 14 18:07:04 2000 From: mal@lemburg.com (M.-A. Lemburg) Date: Fri, 14 Apr 2000 19:07:04 +0200 Subject: [DB-SIG] autonumbers w/ODBC? References: Message-ID: <38F75038.5027C8D7@lemburg.com> "Michal Wallace (sabren)" wrote: > > On Fri, 14 Apr 2000, M.-A. Lemburg wrote: > > > > Is it even possible to get a generated Autonumbe field via ODBC? > > > Microsoft Access seems to be able to do it well enough, but how > > > do you do it with mxODBC? > > > > You don't generate autonumber fields, you declare them when > > you define the table schema. ODBC let's you do this just as > > all other DB API interfaces, but the syntax is of course > > DB specific and not all DBs support this feature. > > Whoops! I meant the generated value from an autonumber field. If I > connect to SQL server or MySQL or whatever, I can add a record, and > access knows/discovers the value of the new ID. > > > Its simplest to use max(id) during insert and then apply > > a few tries to catch simultaneous inserts in case they > > should happen. Works everywhere and doesn't need auto-increment > > columns. > > how would you catch the simultaneous inserts? Trial and error :-) ... I use a for loop which does a few iteration of try:...except:... and fails after that. > In any case, if for whatever reason the database designer has created > an Autonumber field, I'd like my objects to handle it.. The max(ID) > concept seems to have a lot of promise (thanks!) > > Let's say I insert "Homer Simpson" into a table with an autonumber > field. I can get the max(ID) with a select statement, unless If > someone inserts another record right after me. I can cover that > easily enough with something like: > > SELECT MAX(ID), first, last from names > WHERE first="Homer" and last="Simpson" > GROUP BY ID, first, last > > .. But what if two people happen to insert Homer Simpson at the same > time? I mean, if the other fields were always unique, I wouldn't > necessarily need a primary key.. I was heading for emulating auto-increment columns, you seem to be heading in a different direction: that of trying to *use* these columns. I don't think you're going to get far with this since that approach buys you three problems ;-) 1. to detect auto-increment columns 2. to properly insert data into a table using these 3. to get the auto-incremented value used by the DB IMHO, it's better not to use them at all and roll your own database invariant design. One way is using max(id) for this, another the sequence table approach (you just have to make sure it always contains data... not very hard, though: you can use a hook which fills it on demand). > MySQL lets me skip all that and just call a function to get the last > generated ID for my connection... I've seen Access get this result > through ODBC, but I'm having a hard time figuring out how it works, > Is there a function like this built into ODBC, or do you think they > use a set of heuristics along the max(ID) lines..? No. All ODBC gives you is an API which let's you query a column to use for uniquely identifying a table row (not all DBs provide ROWNO values). -- Marc-Andre Lemburg ______________________________________________________________________ Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ From adustman@comstar.net Tue Apr 18 00:01:50 2000 From: adustman@comstar.net (Andy Dustman) Date: Mon, 17 Apr 2000 19:01:50 -0400 (EDT) Subject: [DB-SIG] db-api suggestions / zike data classes In-Reply-To: Message-ID: On Fri, 14 Apr 2000, Michal Wallace (sabren) wrote: > > Hello Everybody :) > > I'm attempting to build an abstraction layer on top of the DB-API, > that gives an object-oriented interface to individual records. Here's > an example: > > > ################################## > > import someDBAPIcompliantModule > dbc = someDBAPIcompiantModule.connect("blah blah") > > import zdc.Record > rec = zdc.Record(dbc, "myTable") > > rec.new() > rec["name"] = "Michal" > rec["age"] = 23 > rec.save() > > > rec.select(name="Fred") > print "Fred is " + rec["age"] + "years old." > # or: > print "Fred is " + rec[1] + "years old." > > ################################## Also take a look at: http://starship.python.net/crew/adustman for SQLDict (it doesn't have it's own page). It has an ObjectBuilder class, which uses table and column specifications to determine what attributes the object has, and when these objects are registered with a SQLDict object, it generates the necessary SQL to SELECT, UPDATE, and DELETE the objects directly. As an example (not guaranteed to work): from SQLDict import MySQLDict, ObjectBuilder class Person(ObjectBuilder): table = "myTable" columns = ["name", "age"] update_columns = columns indices = [ ('name', ['name']), ('age', ['age']) ] def _set_age(self, age): if age<0: raise ValueError, "nobody's that young" self.__dict__['age']=age real_db = MySQLdb.connect(...) db = MySQLDict(real_db) Person().register(db) # register with the database # all three of the following are equivalent p = Person("Michal",23) p = Person(name="Michal", age=23) p = Person() p.name = "Michal" p.age = 23 p.age = -1 # raises ValueError print repr(p) # prints Person("Michal",23) print str(p) # prints Person(name="Michal",age=23) db.insert(p) # INSERT into the database p23 = db.Person.age[23].fetchall() # get everyone who's 23 geezers = db.Person.select(WHERE="WHERE age>=70").fetchall() db.Person.name['Michal'] = p2 # UPDATE del db.Person.name['Michal'] --- The standard SQLDict class will work at least with mxODBC; it is a very simple matter to subclass it to adapt it for other databases, so long as they are DB-API. > First, if I'm just looking at some random connection object, and I > use it to create a cursor object... How can I get the fieldtypes out > of the description? The fieldtypes are arbitrary values that have to > be compared against something back in the module's namespace... But > since this is a random connection object, *I don't know what module > to look in!!!* MySQLdb (and others) export some psuedo-types that can be used for comparison. You can take the type field from the description and make comparisons like t == STRING, or t == NUMBER. This is defined in the DB API interface. > Suppose I have an autonumber / auto_increment / whatever field. I > run an INSERT statement. How do I get the generated number? As far > as I can tell, I have to use a module-specific function call. Wouldn't > this be a fairly useful process to standardize? Useful, yes. Two ways with MySQLdb: One is to use pure SQL and SELECT LAST_INSERT_ID(). The other is to do cursor.insert_id(). Neither is portable, of course. In Solid, I have seen this done as a stored procedure call, so it is a real implementation problem. > I personally don't have any particular need for this at the moment, > but I'm sure it would be nice to have down the line: dbc.tables() to > give a list of tables? Possibly even dbc.queries() or dbc.sprocs() > for providers that had queries and stored procedures.. I'm guessing > most modules have something like this already, but it's no fun without > a standard. :) In most databases, you seem to have to suck this out of the system tables, which have a standard layout. -- andy dustman | programmer/analyst | comstar.net, inc. telephone: 770.485.6025 / 706.549.7689 | icq: 32922760 | pgp: 0xc72f3f1d "Therefore, sweet knights, if you may doubt your strength or courage, come no further, for death awaits you all, with nasty, big, pointy teeth!" From janssen@parc.xerox.com Tue Apr 18 02:57:28 2000 From: janssen@parc.xerox.com (Bill Janssen) Date: Mon, 17 Apr 2000 18:57:28 PDT Subject: [DB-SIG] Python, DB2, Solaris and NT In-Reply-To: Your message of "Thu, 13 Apr 2000 08:28:46 PDT." Message-ID: <00Apr17.185705pdt."3438"@watson.parc.xerox.com> Or perhaps even better, Sparrow (see http://www.parc.xerox.com/istl/projects/sparrow/), which is a Python-implemented system. I wonder if it's freely available? Bill From brydon@claborn.net Tue Apr 18 04:52:28 2000 From: brydon@claborn.net (David Brydon) Date: Mon, 17 Apr 2000 22:52:28 -0500 Subject: [DB-SIG] create table in win32 odbc module Message-ID: <002e01bfa8e9$842a8a50$0500a8c0@dell> This is a multi-part message in MIME format. ------=_NextPart_000_002B_01BFA8BF.9B068960 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hello.=20 I have gotten a lot of use from the wonderful odbc module in the = win32 distribution of Mark Hammond. But the last few days I have been = stumped. I am running on Windows NT 4.0, talking to MS SQL Server. I can = access existing data fine, but am having trouble creating a table from = the python. Can anyone help? The same code run as sql in the database makes the table. The python = script says the table exists if you try to create it twice. No errors = are given. But the table never appears in the MS SQL Enterprise Manager = or Query Analyzer. My code looks like: import dbi, odbc # needed to connect to database db =3D odbc.odbc('TSQL/SA/') # get the database connection cursor =3D db.cursor(DBLogin) # start a cursor sql =3D "create table TestTemp (name text)" print sql print ' ' cursor.execute(sql) =20 sql=3D"insert into TestTemp (name) values ('12345')" print sql print ' ' cursor.execute(sql) =20 cursor.close() db.close() cursor =3D None db =3D None=20 No errors, but no table after it runs! Thanks much, David ------=_NextPart_000_002B_01BFA8BF.9B068960 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Hello. 
    I have gotten a lot of use from = the=20 wonderful odbc module in the win32 distribution of Mark Hammond.  = But the=20 last few days I have been stumped.
   I am running on Windows NT 4.0, talking = to MS SQL=20 Server.  I can access existing data fine, but am having trouble = creating a=20 table from the python.  Can anyone help?
The same code run as sql in the database makes the=20 table.  The python script says the table exists if you try to = create it=20 twice.  No errors are given.  But the table never appears in = the MS=20 SQL Enterprise Manager or Query Analyzer.
My code looks like:
import dbi, odbc # needed to connect to = database
db =3D=20 odbc.odbc('TSQL/SA/') # get the database connection
cursor =3D db.cursor(DBLogin)  # start a = cursor
sql =3D=20 "create table TestTemp (name text)"
print sql
print '=20 '
cursor.execute(sql)       =20
sql=3D"insert into TestTemp (name) values ('12345')"
print = sql
print '=20 '
cursor.execute(sql)       =20
cursor.close()
db.close()
 
cursor =3D None
db =3D None
 
No errors, but no table after it runs!  Thanks = much,=20 David
------=_NextPart_000_002B_01BFA8BF.9B068960-- From sgendler@silcom.com Tue Apr 18 05:44:59 2000 From: sgendler@silcom.com (Sam Gendler) Date: Mon, 17 Apr 2000 21:44:59 -0700 Subject: [DB-SIG] create table in win32 odbc module References: <002e01bfa8e9$842a8a50$0500a8c0@dell> Message-ID: <38FBE84B.9BBD378C@silcom.com> I don't use ODBC, but just here's a guess. 'cursor.commit()' > David Brydon wrote: > > Hello. > I have gotten a lot of use from the wonderful odbc module in the > win32 distribution of Mark Hammond. But the last few days I have been > stumped. > I am running on Windows NT 4.0, talking to MS SQL Server. I can > access existing data fine, but am having trouble creating a table from > the python. Can anyone help? > The same code run as sql in the database makes the table. The python > script says the table exists if you try to create it twice. No errors > are given. But the table never appears in the MS SQL Enterprise > Manager or Query Analyzer. > My code looks like: > import dbi, odbc # needed to connect to database > db = odbc.odbc('TSQL/SA/') # get the database connection > cursor = db.cursor(DBLogin) # start a cursor > sql = "create table TestTemp (name text)" > print sql > print ' ' > cursor.execute(sql) > sql="insert into TestTemp (name) values ('12345')" > print sql > print ' ' > cursor.execute(sql) > cursor.close() > db.close() > > cursor = None > db = None > > No errors, but no table after it runs! Thanks much, David From bkc@murkworks.com Tue Apr 18 15:25:26 2000 From: bkc@murkworks.com (Brad Clements) Date: Tue, 18 Apr 2000 09:25:26 -0500 Subject: [DB-SIG] db-api suggestions / zike data classes In-Reply-To: References: Message-ID: <38FC29FE.12705.145F6D87@localhost> On 17 Apr 2000, at 19:01, Andy Dustman wrote: > On Fri, 14 Apr 2000, Michal Wallace (sabren) wrote: > > I'm attempting to build an abstraction layer on top of the DB-API, > > that gives an object-oriented interface to individual records. Here's an > > example: > > Also take a look at: > > http://starship.python.net/crew/adustman > > for SQLDict (it doesn't have it's own page). It has an ObjectBuilder > class, which uses table and column specifications to determine what > attributes the object has, and when these objects are registered with a > SQLDict object, it generates the necessary SQL to SELECT, UPDATE, and > DELETE the objects directly. As an example (not guaranteed to work): > I've been using SQLDict for a week and I say, it is a really nice peice of work. I'm using it with Zope. My problem was seperating "business logic" from presentation. I wanted an object oriented interface to records, and a mechanism to conveniently use those objects via the Web. SQLDict has given me the former method. I'm working on my own HTMLForm tools that works in conjunction with SQLDict based objects to create basic forms and to represent one-to-one, many-to-one, many- to-many relationships. I'd like to take a look at Andy's HyperText, but starship has been down for a while now. -- Some mods I've made to SQLDict: 1. Added __getitem__ support to SQLDict, and Table items to make lookup easier from Zope. 2. There is a circular reference problem when using the register() method of ObjectBuilder. Tables point to SQLDict, and SQLDict points to table, and Index points to Table and Table points to Index. I've added a _delete() method to SQLDict, Table and Index to help break these references. Its an ugly hack, I'm not sure how to do it nicer. 3. Added onValidate(), onUpdate(), onCreate() dummy methods to ObjectBuilder. I think onValidate() should go in my other Mix-in class, I'll probably move it out of ObjectBuilder. 4. Added an update(), refresh() and delete() method to ObjectBuilder 5. set_keywords() can take an instance object. Brad Clements, bkc@murkworks.com (315)268-1000 http://www.murkworks.com (315)268-9812 Fax netmeeting: ils://ils.murkworks.com AOL-IM: BKClements From adustman@comstar.net Tue Apr 18 14:43:08 2000 From: adustman@comstar.net (Andy Dustman) Date: Tue, 18 Apr 2000 09:43:08 -0400 (EDT) Subject: [DB-SIG] db-api suggestions / zike data classes In-Reply-To: <38FC29FE.12705.145F6D87@localhost> Message-ID: On Tue, 18 Apr 2000, Brad Clements wrote: > I've been using SQLDict for a week and I say, it is a really nice peice of > work. > > I'm using it with Zope. ? Zope is one of the last places I would expect to see SQLDict, due to Zope's own DA interface, but hey, if it works for you... > My problem was seperating "business logic" from presentation. I wanted > an object oriented interface to records, and a mechanism to > conveniently use those objects via the Web. > > SQLDict has given me the former method. I'm working on my own > HTMLForm tools that works in conjunction with SQLDict based objects > to create basic forms and to represent one-to-one, many-to-one, many- > to-many relationships. > > I'd like to take a look at Andy's HyperText, but starship has been down > for a while now. I've sent you a copy separately. If anyone else wants one, just let me know. > Some mods I've made to SQLDict: > > 1. Added __getitem__ support to SQLDict, and Table items to make > lookup easier from Zope. I think I know what you mean. There's a tendency to set a lot of new attributes in a SQLDict objects, i.e. one of the examples is: >>> db.People = db.Table('PEOPLE', [ 'Name', 'Address', 'City', 'State' ]) For that matter, if you use ObjectBuilder and register() the class with the database, it will similarly create attributes within the SQLDict object. > 2. There is a circular reference problem when using the register() > method of ObjectBuilder. Tables point to SQLDict, and SQLDict points > to table, and Index points to Table and Table points to Index. I've added > a _delete() method to SQLDict, Table and Index to help break these > references. > > Its an ugly hack, I'm not sure how to do it nicer. > > 3. Added onValidate(), onUpdate(), onCreate() dummy methods to > ObjectBuilder. I think onValidate() should go in my other Mix-in class, I'll > probably move it out of ObjectBuilder. > > 4. Added an update(), refresh() and delete() method to ObjectBuilder > > 5. set_keywords() can take an instance object. Hold on here... Before you start ripping stuff out and putting them into separate classes, send me patches. I haven't done hardly any development on SQLDict in more than a year. Last thing I did was through in a MySQLDict subclass because I needed it. So it would probably benefit from some fresh ideas. And some of these sound pretty good. -- andy dustman | programmer/analyst | comstar.net, inc. telephone: 770.485.6025 / 706.549.7689 | icq: 32922760 | pgp: 0xc72f3f1d "Therefore, sweet knights, if you may doubt your strength or courage, come no further, for death awaits you all, with nasty, big, pointy teeth!" From bkc@murkworks.com Tue Apr 18 16:02:10 2000 From: bkc@murkworks.com (Brad Clements) Date: Tue, 18 Apr 2000 10:02:10 -0500 Subject: [DB-SIG] db-api suggestions / zike data classes In-Reply-To: References: <38FC29FE.12705.145F6D87@localhost> Message-ID: <38FC3299.20440.14810BB1@localhost> On 18 Apr 2000, at 9:43, Andy Dustman wrote: > On Tue, 18 Apr 2000, Brad Clements wrote: > > > I've been using SQLDict for a week and I say, it is a really nice peice > > of work. > > > > I'm using it with Zope. > > ? Zope is one of the last places I would expect to see SQLDict, due to > Zope's own DA interface, but hey, if it works for you... Yes, Zope has a nice DA interface, but I wanted to be able to build and test the object logic outside of Zope, but be able to use the same code within Zope without changing anything. Zope DAs are nice, but they don't work like a DB-API module. I didn't want to code the business logic in DTML, its not really meant for that. On the other hand, I didn't want to put the logic in a Python extension just to have all the database code in Zope, because the logic part wouldn't have database access without explicitely passing around a Zope DA or SQL Method. This would tie me to Zope too much, and I'd be unable to work on the logic outside of Zope. > > Some mods I've made to SQLDict: > > > > 1. Added __getitem__ support to SQLDict, and Table items to make > > lookup easier from Zope. > > I think I know what you mean. There's a tendency to set a > lot of new attributes in a SQLDict objects, i.e. one of the examples is: > > >>> db.People = db.Table('PEOPLE', [ 'Name', 'Address', 'City', 'State' ]) > > For that matter, if you use ObjectBuilder and register() the class with the > database, it will similarly create attributes within the SQLDict object. > Exactly. Since table points to db, and now db points to the created table, you have a circular reference. To break this, I'd have to do db.People = None, in which case I have to keep track of all the tables I've added to db. db._delete() does the deletion for me. > Hold on here... Before you start ripping stuff out and putting them into > separate classes, send me patches. I haven't done hardly any development on > SQLDict in more than a year. Last thing I did was through in a MySQLDict > subclass because I needed it. So it would probably benefit from some fresh > ideas. And some of these sound pretty good. I'll send it to you. Some of the changes are not as 'pythonic' as your code, but I'm still learning. Brad Clements, bkc@murkworks.com (315)268-1000 http://www.murkworks.com (315)268-9812 Fax netmeeting: ils://ils.murkworks.com AOL-IM: BKClements From gstein@lyra.org Tue Apr 18 20:48:05 2000 From: gstein@lyra.org (Greg Stein) Date: Tue, 18 Apr 2000 12:48:05 -0700 (PDT) Subject: [DB-SIG] collect the tools? (was: db-api suggestions / zike data classes) In-Reply-To: Message-ID: On Tue, 18 Apr 2000, Andy Dustman wrote: > On Tue, 18 Apr 2000, Brad Clements wrote: >... > > SQLDict has given me the former method. I'm working on my own > > HTMLForm tools that works in conjunction with SQLDict based objects > > to create basic forms and to represent one-to-one, many-to-one, many- > > to-many relationships. > > > > I'd like to take a look at Andy's HyperText, but starship has been down > > for a while now. > > I've sent you a copy separately. If anyone else wants one, just let me > know. I think that it would make eminent sense to start listing tools like SQLDict and whatever stuff MAL may have on the DB-SIG home pages. It would certainly help the Python DB community, and would defray posts to this list which are seeking stuff like this. Who has edit rights to the DB SIG pages? If people can send specific URLs and blurbs to that person, they could drop them into a page. (let's not burden the DB SIG page editor with having to discover this stuff on their own) Note: Starship has died. Cheers, -g -- Greg Stein, http://www.lyra.org/ From akuchlin@mems-exchange.org Tue Apr 18 20:46:10 2000 From: akuchlin@mems-exchange.org (Andrew M. Kuchling) Date: Tue, 18 Apr 2000 15:46:10 -0400 (EDT) Subject: [DB-SIG] collect the tools? In-Reply-To: References: Message-ID: <14588.48002.636907.902862@amarok.cnri.reston.va.us> Greg Stein writes: >Who has edit rights to the DB SIG pages? If people can send specific URLs >and blurbs to that person, they could drop them into a page. (let's not >burden the DB SIG page editor with having to discover this stuff on their >own) I do, since I now own the SIG. You can e-mail me pointers to tools; put "DB tool" (or something distinctive) in the subject line so I can filter them out. --amk From gstein@lyra.org Tue Apr 18 21:02:19 2000 From: gstein@lyra.org (Greg Stein) Date: Tue, 18 Apr 2000 13:02:19 -0700 (PDT) Subject: [DB-SIG] collect the tools? In-Reply-To: <14588.48002.636907.902862@amarok.cnri.reston.va.us> Message-ID: On Tue, 18 Apr 2000, Andrew M. Kuchling wrote: > Greg Stein writes: > >Who has edit rights to the DB SIG pages? If people can send specific URLs > >and blurbs to that person, they could drop them into a page. (let's not > >burden the DB SIG page editor with having to discover this stuff on their > >own) > > I do, since I now own the SIG. You can e-mail me pointers to tools; > put "DB tool" (or something distinctive) in the subject line so I can > filter them out. *blink* hehe... I guess I missed that xfer from Michael. Well, this is goodness! I'll forward a dtuple.py reference momentarily... Cheers, -g -- Greg Stein, http://www.lyra.org/ From gstein@lyra.org Tue Apr 18 21:47:52 2000 From: gstein@lyra.org (Greg Stein) Date: Tue, 18 Apr 2000 13:47:52 -0700 (PDT) Subject: [DB-SIG] DB TOOL In-Reply-To: Message-ID: On Tue, 18 Apr 2000, Greg Stein wrote: > On Tue, 18 Apr 2000, Andrew M. Kuchling wrote: > > Greg Stein writes: > > >Who has edit rights to the DB SIG pages? If people can send specific URLs > > >and blurbs to that person, they could drop them into a page. (let's not > > >burden the DB SIG page editor with having to discover this stuff on their > > >own) > > > > I do, since I now own the SIG. You can e-mail me pointers to tools; > > put "DB tool" (or something distinctive) in the subject line so I can > > filter them out. > > *blink* > > hehe... I guess I missed that xfer from Michael. Well, this is goodness! > > I'll forward a dtuple.py reference momentarily... Tool: http://www.lyra.org/greg/python/dtuple.py Info: http://www.lyra.org/greg/python/index.html#dtuple Description: dtuple.py provides a tuple-, dictionary-, or object-based view of the rows returned by a DBAPI module's fetch* methods. It is easy to understand and has a light memory footprint. Performance is quite reasonable for all but the largest data sets. thx, -g -- Greg Stein, http://www.lyra.org/ From j.andrusaitis@konts.lv Wed Apr 19 14:52:37 2000 From: j.andrusaitis@konts.lv (=?iso-8859-1?B?SudrYWJzIEFuZHJ18GFpdGlz?=) Date: Wed, 19 Apr 2000 16:52:37 +0300 Subject: [DB-SIG] DCOracle on HP-UX 11.00 using Oracle 8.1.5 In-Reply-To: Message-ID: <000401bfaa06$86272020$262a949f@konts.lv> Has anyone successfully used DCOracle module on HP-UX 11.00 with Oracle 8.1.5? I managed to compile it statically into Python and stangely it actually worked (at least I was able to fetch some rows:). I am worried about size of the statically linked Python executable - it is around 7Mb (after stripping). Another thing I really need is - ability to use DCOracle with oracle connection established by embedded SQL, as I am embedding Python into C code, which uses embedded SQL to connect. Previously I was using OLD version of DCOracle, and as far I remeber, I wrote code to use embedded SQL connect myself. Maybe someone has implemented such feature into current release of DCOracle? Jekabs Andrušaitis Sistemu analitikis Tieto Konts Financial Systems Kr.Barona 30, Riga, LV-1011, Latvia tel.: (371) 7286660, (371) 7283689 fax: (371) 7243000 e-mail: J.Andrusaitis@konts.lv http://www.konts.lv From petrilli@amber.org Wed Apr 19 15:55:08 2000 From: petrilli@amber.org (Christopher Petrilli) Date: Wed, 19 Apr 2000 10:55:08 -0400 Subject: [DB-SIG] DCOracle on HP-UX 11.00 using Oracle 8.1.5 In-Reply-To: <000401bfaa06$86272020$262a949f@konts.lv>; from j.andrusaitis@konts.lv on Wed, Apr 19, 2000 at 04:52:37PM +0300 References: <000401bfaa06$86272020$262a949f@konts.lv> Message-ID: <20000419105508.B6107@trump.amber.org> Jçkabs Andruðaitis [j.andrusaitis@konts.lv] wrote: > Has anyone successfully used DCOracle module on HP-UX 11.00 with Oracle > 8.1.5? Nope, we don't use HP-UX around here (DC). Having said that, it works fine with other things. Check out the replacement Setup file that I wrote for 8.1.5: http://www.zope.org/Members/petrilli/Oracle8i There are still some open issues with DCOracle that I hope to resolve before the next release: - LOBs don't work in Oracle 8i, yet another gratuitous change - Heavily multi-threaded apps fail under 8i that work fine under 8.0.5. This reuqires a totally different method to fix... *sigh* > I am worried about size of the statically linked Python executable - it is > around 7Mb (after stripping). I ca't speak to the size on HPUX, but on Solaris/Linux, the new Setup file creates a "tiny" shared library... at least by Oracle standards :-) > Another thing I really need is - ability to use DCOracle with oracle > connection established by > embedded SQL, as I am embedding Python into C code, which uses embedded SQL > to connect. can't help you here, it's not a "design requirement" for DCOracle. If you were to write code that would do this correctly, then we would consider integrating it into the DCOracle code-base. Chris -- | Christopher Petrilli | petrilli@amber.org From jmcgraw" Hello all, I'm working with Ovrimos SQL server, an RDBMS that does not provide a Python interface. While they company does provide an ODBC driver, it only works on Win32. The database server is a FreeBSD machine, and I would like to use Python to access it. Am I out of luck? BTW, I'm really getting tired of seeing database vendors provide Perl DBI drivers but nary a mention of Python! Joel Mc Graw DataBill, LLC Voice: 602-415-1234 Fax: 602-415-1255 Email: jmcgraw@databill.com ICQ: 45234166 From gonter@maestria.wu-wien.ac.at Wed Apr 19 17:57:13 2000 From: gonter@maestria.wu-wien.ac.at (Gerhard Gonter) Date: Wed, 19 Apr 2000 18:57:13 +0200 (MES) Subject: [DB-SIG] DCOracle on HP-UX 11.00 using Oracle 8.1.5 In-Reply-To: <20000419160020.02A341CE3C@dinsdale.python.org> from "db-sig-request@python.org" at "Apr 19, 2000 12:00:20 pm" Message-ID: <200004191657.SAA34494@maestria.wu-wien.ac.at> > Return-path: > To: > Date: Wed, 19 Apr 2000 16:52:37 +0300 > Subject: [DB-SIG] DCOracle on HP-UX 11.00 using Oracle 8.1.5 > Has anyone successfully used DCOracle module on HP-UX 11.00 with Oracle > 8.1.5? > I managed to compile it statically into Python and stangely it actually > worked (at least I was able to fetch some rows:). A similar problem: Does anybody know what the correct setup is to produce a shared module on AIX 4.2 for Oracle 7.3.4? I tried to find a solution for several days and finally hacked a Perl script (sorry, I'm not fluent enough in Python yet) that tried several configurations for a night until it evenutally spit out a shared object that actually works. There must be a better way instead of this brute force method. Any comment? +gg -- Gerhard.Gonter@wu-wien.ac.at Fax: +43/1/31336/702 g.gonter@ieee.org Zentrum fuer Informatikdienste, Wirtschaftsuniversitaet Wien, Austria From pehr@eink.com Wed Apr 19 22:02:18 2000 From: pehr@eink.com (pehr anderson) Date: Wed, 19 Apr 2000 17:02:18 -0400 Subject: [DB-SIG] DCOracle only allows one connection? Message-ID: <38FE1EDA.BD3EB3F0@eink.com> Dear Python DB-ers, I'm using Oracle 8.1.5 on RedHat 6.1 with python-1.5.2-7. I've tried DCOracle-1.3.0 ZOracleDA-2.2.0b1-src.tgz ZOracleDA-2.1.0-nonbin.tgz My goal is to use this with Zope. DCOracle seems to only allow one connection per python session. If I try to connect again, it dumps core. I realize I should set up one connection with a long-running process, but for convenience I set up a Zope external method that would open a connection, do a transaction and close. Has anyone else run into this? I'm only using one database so persistant connections will work for my app. I imagine some people will require better behavior. -pehr #!/usr/bin/env python import sys, DCOracle def test(): dbc=DCOracle.Connect("falafel/flatbread") c = dbc.cursor() c.close() dbc.commit() dbc.close() test() print "Finished 1" test() print "Finished 2" [root@linfoo Extensions]# ./crash.py Finished 1 Segmentation fault (core dumped) Here is a sample GDB Session... not sure if this is useful: This GDB was configured as "i386-redhat-linux". (gdb) run Starting program: /usr/bin/python Python 1.5.2 (#1, Sep 17 1999, 20:15:36) [GCC egcs-2.91.66 19990314/Linux (egcs- on linux-i386 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import DCOracle >>> d = DCOracle.Connect("falafel/flatbread") >>> c = d.cursor() >>> c.close() >>> d.close() >>> d = DCOracle.Connect("falafel/flatbread") Program received signal SIGSEGV, Segmentation fault. 0x400a24ea in chunk_alloc (ar_ptr=0x40137040, nb=16) at malloc.c:2700 2700 malloc.c: No such file or directory. (gdb) bt #0 0x400a24ea in chunk_alloc (ar_ptr=0x40137040, nb=16) at malloc.c:2700 #1 0x400a240a in __libc_malloc (bytes=8) at malloc.c:2643 #2 0x806c01a in ?? () #3 0x806c546 in ?? () #4 0x8064a09 in ?? () #5 0x8054354 in ?? () #6 0x8051e49 in ?? () #7 0x805421b in ?? () #8 0x8053e3a in ?? () #9 0x8065efb in ?? () #10 0x8053f41 in ?? () #11 0x8053e48 in ?? () #12 0x8053035 in ?? () #13 0x805134b in ?? () #14 0x805f874 in ?? () #15 0x805ef02 in ?? () #16 0x805edb7 in ?? () #17 0x805ed17 in ?? () #18 0x804fc72 in ?? () #19 0x804f7b6 in ?? () #20 0x400621eb in __libc_start_main (main=0x804f7a8, argc=1, argv=0xbffffb04, init=0x804edf4, fini=0x8084c8c, rtld_fini=0x4000a610 <_dl_fini>, stack_end=0xbffffafc) at ../sysdeps/generic/libc-start.c:90 From petrilli@amber.org Wed Apr 19 22:06:17 2000 From: petrilli@amber.org (Christopher Petrilli) Date: Wed, 19 Apr 2000 17:06:17 -0400 Subject: [DB-SIG] DCOracle only allows one connection? In-Reply-To: <38FE1EDA.BD3EB3F0@eink.com>; from pehr@eink.com on Wed, Apr 19, 2000 at 05:02:18PM -0400 References: <38FE1EDA.BD3EB3F0@eink.com> Message-ID: <20000419170617.D6107@trump.amber.org> pehr anderson [pehr@eink.com] wrote: > I'm using Oracle 8.1.5 on RedHat 6.1 with python-1.5.2-7. > I've tried DCOracle-1.3.0=20 > ZOracleDA-2.2.0b1-src.tgz > ZOracleDA-2.1.0-nonbin.tgz =20 >=20 > My goal is to use this with Zope.=13 >=20 > DCOracle seems to only allow one connection per python > session. If I try to connect again, it dumps core. > I realize I should set up one connection with a > long-running process, but for convenience I set up=20 > a Zope external method that would open a connection,=20 > do a transaction and close.=20 Wow, his is amazingly ineffecient, there's a *HUGE* overhead in creating connections. > Has anyone else run into this? I'm only using one > database so persistant connections will work for my app. > I imagine some people will require better behavior. Yes, it has to do with stupidity in 8.1.5 that blows up with the "single statement login" that 8.0 uses. So we've got some patches we're tsting that fix it on 8.1.5, but of course don't work on 8.0.5. o there's a huge amount of conditional code :/ Chris --=20 | Christopher Petrilli | petrilli@amber.org From yelled@yahoo.com Mon Apr 24 17:13:25 2000 From: yelled@yahoo.com (S. Hoon Yoon) Date: Mon, 24 Apr 2000 09:13:25 -0700 (PDT) Subject: [DB-SIG] dcl_result_drop: HELP! Message-ID: <20000424161325.10426.qmail@web2005.mail.yahoo.com> Hi, I am attempting to compile Sybase_0.4 module on Solaris box. I had few problems, but I got it compiled. Now everytime I import it I get: symbol dcl_result_drop: referenced symbol not found I had to eliminate -lsybtcl and -linsck from the Makefile, because I do not have those lib. Is that the prb? If so, then where do I get it. If not why do I have this problem? Thanks, Hoon, P.S.: Pls e-mail directly to this yelled@yahoo.com address. I have included all errors. ---------------------- ld -G Sybase.o bulkcopy.o cmd.o conn.o connect.o cursor.o -L/u82/sr/sybase/lib -lblk -lct -lcs -lsybtcl -lcomn -linsck -lintl -o Sybase.so ld: cannot open -lsybtcl: No such file or directory make: *** [Sybase.so] Error 1 ld -G Sybase.o bulkcopy.o cmd.o conn.o connect.o cursor.o -L/u82/sr/sybase/lib -lblk -lct -lcs -lcomn -linsck -lintl -o Sybase.so ld: cannot open -linsck: No such file or directory SYBLIB = $(SYBROOT)/lib -lblk -lct -lcs -lcomn -lintl quants32 hyoon/tmp/Sybase-0.4$ python Python 1.6a2 (#4, Apr 20 2000, 11:05:42) [GCC 2.8.1] on sunos5 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import Sybase Traceback (most recent call last): File "", line 1, in ? ImportError: ld.so.1: python: fatal: relocation error: file /u82/sr/sybase/lib/libct.so: symbol dcl_result_drop: referenced symbol not found __________________________________________________ Do You Yahoo!? Send online invitations with Yahoo! Invites. http://invites.yahoo.com From yelled@yahoo.com Mon Apr 24 23:45:47 2000 From: yelled@yahoo.com (S. Hoon Yoon) Date: Mon, 24 Apr 2000 15:45:47 -0700 (PDT) Subject: [DB-SIG] dcl_result_drop:pls ignore last msg Message-ID: <20000424224547.11987.qmail@web2005.mail.yahoo.com> Hi, Found out what's wrong. I messed around with wrong Setup.in file. I got it compiled. thanks, Hoon, __________________________________________________ Do You Yahoo!? Send online invitations with Yahoo! Invites. http://invites.yahoo.com From yelled@yahoo.com Wed Apr 26 18:20:13 2000 From: yelled@yahoo.com (S. Hoon Yoon) Date: Wed, 26 Apr 2000 10:20:13 -0700 (PDT) Subject: [DB-SIG] DATETIME conversion for Sybase module 0.5 Message-ID: <20000426172013.28010.qmail@web2001.mail.yahoo.com> Hi, I am using Sybase module 0.5 on Solaris and I am trying to take resulting value from my cursor which is: >>> desc[1] holds cursor description ('date', , 0, 8, 0, 0, 0) >>> m[1] the int DATETIME value that I wish to convert 950648261 I have mxDateTime installed v1.3.0. Pls, e-mail back to yelled@yahoo.com. Thanks, Hoon, BTW: The homepage http://www.itga.com.au/~djc/sybase.html is no good __________________________________________________ Do You Yahoo!? Send online invitations with Yahoo! Invites. http://invites.yahoo.com From yelled@yahoo.com Wed Apr 26 20:38:56 2000 From: yelled@yahoo.com (S. Hoon Yoon) Date: Wed, 26 Apr 2000 12:38:56 -0700 (PDT) Subject: [DB-SIG] Pls ignore last: Thanks! Message-ID: <20000426193856.22575.qmail@web2001.mail.yahoo.com> Hi, I solved the problem with DATETIME. It was just mktime format. I found it by reading the C code underneath it. I still would appreciate any info that anyone has for the Sybase Module 0.5. Any docs and any information about NT compilation. It's excellent module and I would love to have native access from NT so I can use same code on both NT and Solaris. Thanks again, Hoon, __________________________________________________ Do You Yahoo!? Send online invitations with Yahoo! Invites. http://invites.yahoo.com From pieper@viaregio.de Fri Apr 28 10:03:53 2000 From: pieper@viaregio.de (Oliver Pieper) Date: Fri, 28 Apr 2000 11:03:53 +0200 Subject: [DB-SIG] Remote connection to Oracle DB possible? Message-ID: <390953F9.6F1EA49E@viaregio.de> Hello, I hope I found the right mailing list to ask that question. If not, please point me in the right direction. What I'd like to know: is there a way to connect Python/Zope to an Oracle database on a remote server (over an Internet connection). The readmes of DCOracle and ZOracleDA mention environment variables that have to be set to local Oracle paths, which seems to imply that you can only connect to a DB on the same machine. Is this correct? If so, is there any other way to make a remote connection to Oracle? Thanks in advance! Oliver -- Oliver Pieper E: pieper@viaregio.de W: www.oliverpieper.de From mal@lemburg.com Fri Apr 28 11:30:46 2000 From: mal@lemburg.com (M.-A. Lemburg) Date: Fri, 28 Apr 2000 12:30:46 +0200 Subject: [DB-SIG] Remote connection to Oracle DB possible? References: <390953F9.6F1EA49E@viaregio.de> Message-ID: <39096856.F5B098F1@lemburg.com> Oliver Pieper wrote: > > Hello, > > I hope I found the right mailing list to ask that question. If not, please point me in the right direction. I guess so :-) > What I'd like to know: is there a way to connect Python/Zope to an Oracle database on a remote server (over an Internet connection). The readmes of DCOracle and ZOracleDA mention environment variables that have to be set to local Oracle paths, which seems to imply that you can only connect to a DB on the same machine. Is this correct? > > If so, is there any other way to make a remote connection to Oracle? You could use an ODBC-ODBC bridge or one of the ODBC multi-tier driver kits together with mxODBC and the recently announced Zope DA for it. -- Marc-Andre Lemburg ______________________________________________________________________ Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ From Yury Don Fri Apr 28 11:53:44 2000 From: Yury Don (Yury Don) Date: Fri, 28 Apr 2000 16:53:44 +0600 Subject: [DB-SIG] Dbf interface to python Message-ID: <8703.000428@vpcit.ru> Hello All, I need to work with foxpro dbf files from python (read, write and use indexes cdx and idx). Does such interface in python exist? -- Best regards, Yury ICQ 11831432 mailto:yura@vpcit.ru From j.andrusaitis@konts.lv Fri Apr 28 12:15:03 2000 From: j.andrusaitis@konts.lv (=?ISO-8859-1?B?SudrYWJzIEFuZHJ18GFpdGlz?=) Date: Fri, 28 Apr 2000 14:15:03 +0300 Subject: [DB-SIG] Remote connection to Oracle DB possible? In-Reply-To: <39096856.F5B098F1@lemburg.com> Message-ID: <000001bfb103$014e7340$262a949f@konts.lv> If you have Oracle Net installed and have properly configured TNS listener to access remote databases (you need things configured on both machines - server where Oracle runs and client machine as well) (if you can connect to database using Oracle 'sqlplus' program), you can also connect to it using DCOracle. Main environment variable, which should be used is ORACLE_SID, which is alias for instance configured in (see below). Listener configuration is stored in the $ORACLE_HOME/network/admin/tnsnames.ora file, and each record has following example structure: BIGBOYMAIN = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS (PROTOCOL = TCP)(HOST = bigboy)( PORT = 1521 )) (ADDRESS (PROTOCOL = TCP)(HOST = bigboy)( PORT = 1526 )) ) (CONNECT_DATA = ( SID = MAIN ) ) ) Where: BIGBOYMAIN is name of alias (used in ORACLE_SID) bigboy is Oracle server machine host/ip 1521/1526 are port numbers to connect to Oracle on server machine MAIN is Oracle instance name to use on server machine If you set ORACLE_SID in environment, then you can use 'username/password' in your connect string, otherwise you have to use 'username/password@instance'. Jekabs Andrušaitis Sistemu analitikis Tieto Konts Financial Systems Kr.Barona 30, Riga, LV-1011, Latvia tel.: (371) 7286660, (371) 7283689 fax: (371) 7243000 e-mail: J.Andrusaitis@konts.lv http://www.konts.lv From ajung@sz-sb.de Fri Apr 28 12:17:40 2000 From: ajung@sz-sb.de (Andreas Jung) Date: Fri, 28 Apr 2000 13:17:40 +0200 Subject: [DB-SIG] How to use DCOracle and LOBs in Oracle 8i ???? Message-ID: <20000428131739.A20818@sz-sb.de> Return-Path: Received: from saarland.sz-sb.de by sabsol.sz-sb.de (SMI-8.6/SMI-SVR4) id MAA08926; Fri, 28 Apr 2000 12:48:35 +0200 Received: from dinsdale.python.org (dinsdale.cnri.reston.va.us [132.151.1.21]) by saarland.sz-sb.de (8.8.8/8.8.8) with ESMTP id MAA16447 for ; Fri, 28 Apr 2000 12:48:33 +0200 (MET DST) Received: from dinsdale.python.org (localhost [127.0.0.1]) by dinsdale.python.org (Postfix) with ESMTP id DCA5B1CD70; Fri, 28 Apr 2000 06:48:12 -0400 (EDT) Delivered-To: python-list@python.org Received: from saarland.sz-sb.de (saarland.sz-sb.de [212.88.192.10]) by dinsdale.python.org (Postfix) with ESMTP id 2E6401CD5D for ; Fri, 28 Apr 2000 06:48:09 -0400 (EDT) Received: from milliways.sz-sb.de (milliways.sz-sb.de [10.2.0.64]) by saarland.sz-sb.de (8.8.8/8.8.8) with ESMTP id MAA16378 for ; Fri, 28 Apr 2000 12:48:09 +0200 (MET DST) Received: (from ajung@localhost) by milliways.sz-sb.de (8.9.3+Sun/8.9.1) id MAA21396 for python-list@python.org; Fri, 28 Apr 2000 12:48:09 +0200 (MET DST) Date: Fri, 28 Apr 2000 12:48:08 +0200 From: Andreas Jung To: python-list@python.org Subject: How to use DCOracle and LOBs in Oracle 8i ???? Message-ID: <20000428124808.A21389@sz-sb.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.1.11i Sender: python-list-admin@python.org Errors-To: python-list-admin@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.0beta3 Precedence: bulk List-Id: General discussion list for the Python programming language After reading old postings concerning DCOracle and LOBs I can not solve the following problem: I have a table under Oracle 8i with a NCLOB field. The base character set for the complete database it UTF8. My first problem with DCOracle was an ORA-12704 character set mismatch error when I tried to insert an instance of DCOracle.dbi.dbiRaw() in to the database. My current code looks like this (the table contains the NCLOB field 'content'): lob = 'very long text .....' raw = DCOracle.dbi.dbiRaw(lob) com = 'insert into tab (docnum,content) values(:x,translate(:y using nchar_cs))' curs.execute(com,x='1234',y=raw) This works for LOBs with less than 4000 bytes. For longer LOBs I get the following error message: ORA-01461 can bind a LONG value only for insert into a LONG column. Now...how can I store larger LOBs with more than 4000 bytes ? I have read something about a dbms_lob package but I have really no idea how to use it. Has anyone a working solution or a code example ?! Thanks a lot for any hint, Andreas -- http://www.python.org/mailman/listinfo/python-list From mal@lemburg.com Fri Apr 28 13:15:00 2000 From: mal@lemburg.com (M.-A. Lemburg) Date: Fri, 28 Apr 2000 14:15:00 +0200 Subject: [DB-SIG] Dbf interface to python References: <8703.000428@vpcit.ru> Message-ID: <390980C4.3901DE93@lemburg.com> Yury Don wrote: > > Hello All, > > I need to work with foxpro dbf files from python (read, write and use > indexes cdx and idx). Does such interface in python exist? If on Windows, try the ODBC drivers available from MS (in their database toolkit) together with one of the available Python ODBC interfaces. -- Marc-Andre Lemburg ______________________________________________________________________ Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ From sabaini@niil.at Fri Apr 28 17:39:46 2000 From: sabaini@niil.at (Peter Sabaini) Date: Fri, 28 Apr 2000 18:39:46 +0200 (CEST) Subject: [DB-SIG] Re: How to use DCOracle and LOBs in Oracle 8i ???? In-Reply-To: <20000428124808.A21389@sz-sb.de> Message-ID: i do it with prepare() something like: --------- py snip -------------- conn=Connect( "%s/%s@%s" % (user,pw,srv) ) # klz_artikel_union's second col is long h=conn.prepare( """insert into klz_artikel_union values ( :p1, :p2 )""" ) # getFullText() is usually up to 20kbyte h.execute( ( oa.getId(), oa.getFullText() ) ) --------- py snip -------------- works for me. hth peter. On Fri, 28 Apr 2000, Andreas Jung wrote: :After reading old postings concerning DCOracle and LOBs I :can not solve the following problem: : :I have a table under Oracle 8i with a NCLOB field. The base :character set for the complete database it UTF8. My first :problem with DCOracle was an ORA-12704 character set mismatch error when :I tried to insert an instance of DCOracle.dbi.dbiRaw() in to the database. : : :My current code looks like this (the table contains the NCLOB field 'content'): : : :lob = 'very long text .....' :raw = DCOracle.dbi.dbiRaw(lob) : :com = 'insert into tab (docnum,content) values(:x,translate(:y using nchar_cs))' :curs.execute(com,x='1234',y=raw) : : :This works for LOBs with less than 4000 bytes. For longer LOBs I get the following error :message: ORA-01461 can bind a LONG value only for insert into a LONG column. : :Now...how can I store larger LOBs with more than 4000 bytes ? I have read something :about a dbms_lob package but I have really no idea how to use it. : :Has anyone a working solution or a code example ?! : : :Thanks a lot for any hint, :Andreas : : : : -- _________________________________________________ peter sabaini, mailto: sabaini@niil.at ------------------------------------------------- From ajung@sz-sb.de Sat Apr 29 16:12:20 2000 From: ajung@sz-sb.de (Andreas Jung) Date: Sat, 29 Apr 2000 17:12:20 +0200 Subject: [DB-SIG] Re: How to use DCOracle and LOBs in Oracle 8i ???? In-Reply-To: ; from sabaini@niil.at on Fri, Apr 28, 2000 at 06:39:46PM +0200 References: <20000428124808.A21389@sz-sb.de> Message-ID: <20000429171220.A23493@sz-sb.de> On Fri, Apr 28, 2000 at 06:39:46PM +0200, Peter Sabaini wrote: > > > i do it with prepare() This might work however Oracle 8i crashes with this approach somewhere in the Oracle libraries :-( Andreas