From patrick@swdev.com Wed Sep 2 06:56:45 1998 From: patrick@swdev.com (Patrick Curtain) Date: Tue, 01 Sep 1998 21:56:45 -0800 Subject: [DB-SIG] SQL storage for Python objects Message-ID: <35ECDE19.F093D6CA@swdev.com> Okay, this is probably the most common question and might already be solved. OR, it might be one of those thorny things that noone really has a solution to. Has anyone developed a useful idiom or pattern for storing python objects to relational databases? Said another way, is there a well-defined API that improves on simply embedding all the SQL for the operations on an object? So far, I'm simply including a method for each object that, given a key value, attempts to query the db (i'm using MySQL for now) for that object, populate the members and so on. I provide the class with a write method, a read method and a delete method. Another way to go about this, which i've also used, is to simply have a function that grabs all the data from the db using the fetchall method then iterates over the returned list of records and creates an object instance of that type using the record as the argument to __init__. I'm getting the work done, i guess. Just hoping that someone's thought through a better, more elegant way to go about it. I suppose in some ways i'm also pining for an OpenSource alternative to GemStone/Smalltalk. The object's storage was so intrinsic that you never had to think about it. :) Thanks for any help and ideas! --p ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Patrick Curtain, Husband & Father (I also write Software) patrick@swdev.com, http://www.swdev.com/ From gstein@lyra.org Wed Sep 2 08:05:04 1998 From: gstein@lyra.org (Greg Stein) Date: Wed, 02 Sep 1998 00:05:04 -0700 Subject: [DB-SIG] SQL storage for Python objects References: <35ECDE19.F093D6CA@swdev.com> Message-ID: <35ECEE20.1462C403@lyra.org> Joel Shprentz presented a paper at last year's conference on something that is probably what you're looking for. It's online at: http://www.python.org/workshops/1997-10/proceedings/shprentz.html cheers, -g Patrick Curtain wrote: > > Okay, > > this is probably the most common question and might already be solved. > OR, it might be one of those thorny things that noone really has a > solution to. > > Has anyone developed a useful idiom or pattern for storing python > objects to relational databases? Said another way, is there a > well-defined API that improves on simply embedding all the SQL for the > operations on an object? > > So far, I'm simply including a method for each object that, given a key > value, attempts to query the db (i'm using MySQL for now) for that > object, populate the members and so on. I provide the class with a > write method, a read method and a delete method. > > Another way to go about this, which i've also used, is to simply have a > function that grabs all the data from the db using the fetchall method > then iterates over the returned list of records and creates an object > instance of that type using the record as the argument to __init__. > > I'm getting the work done, i guess. Just hoping that someone's thought > through a better, more elegant way to go about it. I suppose in some > ways i'm also pining for an OpenSource alternative to > GemStone/Smalltalk. The object's storage was so intrinsic that you > never had to think about it. :) > > Thanks for any help and ideas! > --p -- Greg Stein (gstein@lyra.org) execfile("disclaimer.py") From shprentz@bdm.com Wed Sep 2 12:18:45 1998 From: shprentz@bdm.com (Joel Shprentz) Date: Wed, 02 Sep 1998 07:18:45 -0400 Subject: [DB-SIG] SQL storage for Python objects In-Reply-To: <35ECEE20.1462C403@lyra.org> References: <35ECDE19.F093D6CA@swdev.com> Message-ID: <199809021117.HAA12042@mail.his.com> Since the 1997 Python conference, I have continued to use and improve my system for storing Python objects in relational databases. I will try to get a current version onto Starship. For now, visit for my conference slides and the 1997 code. Some Background I've been using Python to develop intranet applications that connect to Sybase. I followed the design strategies described by Peter Coad in his book, "Object Models: Strategies, Patterns and Applications." (See a description of the book on amazon.com at or visit the Object International web site [when it gets fixed] at [hint: look at the free stuff].) In an appendix, Coad outlined his data access approach, which I implemented in Python. The Architecture Each database table holds objects from a persistent object class. The system uses field values from retreived database records to instantiate Python objects. New and updated objects are stored in the database. Numeric, text, date, and BLOB database field types map well to Python object attributes. More work is required to support attributes that contain other Python objects. For example, an employee object has a department attribute that contains a department object. All of the employees in the same department would share the same department object. We want to ask the employee object, "What is your department?" and receive a department object in response. We also want to ask the department object, "Who are your employees?" and receive a list of employee objects in response. As new objects are saved to the database, they are assigned a unique number (within their class). These ID numbers support the persistent storage of object linkages. Continuing the example, the employee table contains a departementID field. When a employee object is saved to the database, its database record holds only the ID number of the employee's department, not the entire department object. The department object will have been previously stored in another table. When the employee record is read from the database, the department ID is saved in the employee object. Later, if the department is requested, it can be retrieved from the database by its unique ID number. Caching makes this operation more efficient. A similar lazy execution is implemented for large text fields and BLOBS. The system retrieves these from the database only when asked. Implementation A collection of template files specify the object model. Each template file contains a list of object attributes and their database representation. A "buildObject" program parses the template files and generates the Python code to implement them. The generated code includes these capabilities: - Create, index, and drop database tables. - Create, retrieve, update, and delete objects. - Get and update object attributes. - Defer retrieval of long text, BLOB, and object attributes until needed. - Cache objects for improved performance. - Support row limits, transactions, and multitasking if available. Through class inheritance, a programmer can replace or enhance the generated code. In practice, most of the code customizations fall into a few categories: - Reformat attributes for display (e.g., combine first and last name). - Validate, restrict, or cascade updates to attributes. - Perform summarization or calculation - Retrieve objects based on complex criteria At 12:05 AM 9/2/98 -0700, Greg Stein wrote: >Joel Shprentz presented a paper at last year's conference on something >that is probably what you're looking for. It's online at: > >http://www.python.org/workshops/1997-10/proceedings/shprentz.html > >Patrick Curtain wrote: >> Has anyone developed a useful idiom or pattern for storing python >> objects to relational databases? Said another way, is there a >> well-defined API that improves on simply embedding all the SQL for the >> operations on an object? -- Joel Shprentz (202) 863-3487 BDM Federal, Inc. shprentz@bdm.com 1501 BDM Way McLean, VA 22102 From adustman@comstar.net Wed Sep 2 21:53:39 1998 From: adustman@comstar.net (Andy Dustman) Date: Wed, 2 Sep 1998 16:53:39 -0400 (EDT) Subject: [DB-SIG] SQL storage for Python objects In-Reply-To: <35ECDE19.F093D6CA@swdev.com> Message-ID: On Tue, 1 Sep 1998, Patrick Curtain wrote: > Has anyone developed a useful idiom or pattern for storing python > objects to relational databases? Said another way, is there a > well-defined API that improves on simply embedding all the SQL for the > operations on an object? I've got an SQLDict module that I developed for internal use. It basically wraps a dictionary-like interface around a Python DB-API SQL database. Once I had the basic idea, it was ridiculously simple to write. There are some Builder classes which can be used to make useful objects that the database knows how to handle. For example, for the schema: Create table Users ( Handle varchar, UNIXpasswd varchar, Mailbox varchar not null, DomainName varchar not null references MailDomains, ... primary key (Mailbox, DomainName) ) ; I can make a object which conforms to this: class User(ObjectBuilder): table = 'Users' columns = ['Handle', 'Mailbox', 'DomainName', 'UNIXpasswd', ...] updatecolumns = columns[3:] indices = [ ('Handle', ['Handle']), ('Email', ['Mailbox', 'DomainName']), ('Domain', ['DomainName'])] Once I make a SQLDict object, I can do: db.User = User().register(db) u = db.User.Handle['freddy'].fetchone() u2 = db.User.Email['fred','nowhere.org'].fetchone() ul = db.User.Domain['nowhere.org'].fetchall() Object attributes are those listed in columns. updatecolumns is used so that certain columns are not updated (to avoid referential integrity problems). u.Handle='frederick' db.User.Handle['freddy'] = u del db.User.Email['joe','blow.com'] Fancier stuff is possible: db.User.delete( (1,), WHERE="WHERE Active <>?") If you'd rather user your own objects than ObjectBuilder subclasses, you can also make it use tuples instead of objects. I'll see if I can release this code, but it's only like 100 lines of actual code. -- Andy Dustman WW Charles Babbage: ComStar Communications Corp. BB He never used Linux, (706) 549-7689 | PGP KeyID=0xC72F3F1D D? and now, he's dead. From shprentz@bdm.com Thu Sep 3 11:50:01 1998 From: shprentz@bdm.com (Joel Shprentz) Date: Thu, 03 Sep 1998 06:50:01 -0400 Subject: [DB-SIG] SQL storage for Python objects In-Reply-To: <199809021117.HAA12042@mail.his.com> References: <35ECEE20.1462C403@lyra.org> <35ECDE19.F093D6CA@swdev.com> Message-ID: <199809031048.GAA24881@mail.his.com> At 07:18 AM 9/2/98 -0400, I wrote: >Since the 1997 Python conference, I have continued to use and >improve my system for storing Python objects in relational databases. >I will try to get a current version onto Starship. The current version is now available on my Starship web site: -- Joel Shprentz (202) 863-3487 BDM Federal, Inc. shprentz@bdm.com 1501 BDM Way McLean, VA 22102 From alexan@unicorn.micex.ru Tue Sep 8 13:17:49 1998 From: alexan@unicorn.micex.ru (Alexander Kuznetsov) Date: Tue, 08 Sep 1998 16:17:49 +0400 Subject: [DB-SIG] Anounce! Kinfxdb and Kinterbasdb released! Message-ID: <35F5206D.525A2219@unicorn.micex.ru> Hello, Python world!
I've put Informix and Interbase modules on http site.

Kinfxdb:
    http://thor.prohosting.com/~alexan/pub/Kinfxdb/
    I've renamed my new Informixdb module to Kinfxdb.
    Proved to work fine with Informix SE 7.* and Informix Online Dinamic server 7.*  on Linux
    and HP-UX. Other platforms haven't been tested. Please try it and report of results to the sig and me.

Kinterbasdb:
    http://thor.prohosting.com/~alexan/Kinterbasdb/
    My Interbasedb module was also renamed to Kinterbasdb.
    Works fine with Interbase 4.0 and 5.0 on Linux and HP-UX.
    It Also works with interbase 3.3 if4.0 client libraries linked to it.

I am planing to write some brief doc for both modules.

Send me your comments.

-- 
Alexander Kuznetsov, alexan@unicorn.micex.ru
  From guido@CNRI.Reston.Va.US Mon Sep 14 16:05:23 1998 From: guido@CNRI.Reston.Va.US (Guido van Rossum) Date: Mon, 14 Sep 1998 11:05:23 -0400 Subject: [DB-SIG] Our answer to Perl's DBI interface? Message-ID: <199809141505.LAA11090@eric.CNRI.Reston.Va.US> This just got posted in the newsgroup. How does Python measure up? --Guido van Rossum (home page: http://www.python.org/~guido/) ------- Forwarded Message Date: Mon, 14 Sep 1998 16:15:47 +0200 From: Jochen Wiedmann To: python-list@cwi.nl Subject: Re: Please advise: How to migrate from FoxPro to platform independent database development. Alan Vlach wrote: > What path makes the most sense? I'm thinking along these lines: > > Basic core language: perl or python > GUI: Tk > Database: PostgreSQL or mSQL If portability is an issue: Choose Perl! Perl´s DBI interface is highly portable. (Of course different SQL peculiarities remain.) I am making CGI, ISAPI or mod_perl developments that run on engines as different as MS Access Adabas Oracle MySQL (much more recommendable than mSQL, btw!) mSQL PostgreSQL CSV files (via DBD::CSV) with little to no modifications under operatins systems as different as Linux, Solaris, WinNT and Win95. Of course one needs some knowledge, for example I had to learn that one should use only uppercased table and column names. Bye, Jochen ------- End of Forwarded Message From robert@ispalliance.net Mon Sep 14 22:34:03 1998 From: robert@ispalliance.net (Robert Saunders) Date: Mon, 14 Sep 1998 17:34:03 -0400 Subject: [DB-SIG] Informixdb question ? Message-ID: <3.0.32.19980914173403.010419ec@america.net> I am new to Python and am looking to implement an interface to some of our existing end user support code that accesses an Informix SE database. My problem is directly related to the informixdb code. I compiled the informixdb code and copied _informixdb.so to /usr/local/lib/python1.5 as well as the *.py and *.pyc. When I type, import informixdb, I get the following error: Python 1.5.1 (#1, Aug 27 1998, 23:18:57) [GCC 2.8.1] on sunos5 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import informixdb Traceback (innermost last): File "", line 1, in ? ImportError: dynamic module does not define init function (initinformixdb) >>> I checked the ifxdbmodule.ec and found init_informixdb remarked out of the code with initinformixdb in its place. In a vain attempt to fix code I don't understand I remarked out init_informixdb and marked in initinformixdb. Neither attempt worked. Any help would be greatly appreciated. Bob Saunders From alexan@unicorn.micex.ru Tue Sep 15 08:59:46 1998 From: alexan@unicorn.micex.ru (Alexander Kuznetsov) Date: Tue, 15 Sep 1998 11:59:46 +0400 Subject: [DB-SIG] Informixdb question ? References: <3.0.32.19980914173403.010419ec@america.net> Message-ID: <35FE1E72.D5CBA472@unicorn.micex.ru> Robert Saunders wrote: > I am new to Python and am looking to implement an interface to some of our > existing end user support code that accesses an Informix SE database. > My problem is directly related to the informixdb code. I compiled the > informixdb code and copied _informixdb.so to /usr/local/lib/python1.5 as > well as the *.py and *.pyc. > When I type, import informixdb, I get the following error: > > Python 1.5.1 (#1, Aug 27 1998, 23:18:57) [GCC 2.8.1] on sunos5 > Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam > >>> import informixdb > Traceback (innermost last): > File "", line 1, in ? > ImportError: dynamic module does not define init function (initinformixdb) > >>> > > I checked the ifxdbmodule.ec and found init_informixdb remarked out of the > code with initinformixdb in its place. In a vain attempt to fix code I > don't understand I remarked out init_informixdb and marked in initinformixdb. > Neither attempt worked. > Any help would be greatly appreciated. > > Bob Saunders > > _______________________________________________ > DB-SIG maillist - DB-SIG@python.org > http://www.python.org/mailman/listinfo/db-sig Use Kinfxdb for best. Proved to work with Informix SE 7.* on Linux. -- Alexander Kuznetsov, alexan@unicorn.micex.ru From pgodman@halcyon.com Wed Sep 16 01:36:51 1998 From: pgodman@halcyon.com (Peter Godman) Date: Tue, 15 Sep 1998 17:36:51 -0700 (PDT) Subject: [DB-SIG] Re: Sybase module In-Reply-To: <199809152337.JAA06034@fulcrum.com.au> Message-ID: On Wed, 16 Sep 1998, Richard Jones wrote: > > What's the official status of your Sybase module? Your starship web > page looks like it hasn't been updated for quite some time, and > there's messages in the python-list archives about you having patches > but not applying them. > > I can't really offer to take over support of the Sybase module > (yet) since I am totally new to it (having moved over from Oracle). I > just want to try it out and know it's stable for simple DML > statements. > > > Richard > Hello Richard. I do have a couple of patches that I haven't applied, due to not being able to test them. One fixes alignment issues for OSF1, and the other provides a fixed-point implementation for MONEY types. I've asked if someone else wants to take over maintainership of the module before, but with no responses. Where did you see the comments about unapplied patches? unfortunately they were not forwarded to me. There are fewer than ten people who have told me they are using the module. There may be more lurkers. I honestly don't know who's using it. Until I hear that someone else will maintain, I'll try to at least make available the patches I get, even if I can't test them. Thanks, Peter Godman > -- > Richard Jones, developer at the Fulcrum Consulting Group > [signature in the works...] > > From raf@comdyn.com.au Wed Sep 16 02:51:17 1998 From: raf@comdyn.com.au (raf) Date: Wed, 16 Sep 1998 11:51:17 +1000 Subject: [DB-SIG] Re: Sybase module Message-ID: <199809160151.LAA03896@mali.comdyn.com.au> Peter Godman wrote: >On Wed, 16 Sep 1998, Richard Jones wrote: >> What's the official status of your Sybase module? Your starship web >> page looks like it hasn't been updated for quite some time, and >> there's messages in the python-list archives about you having patches >> but not applying them. >> >> I can't really offer to take over support of the Sybase module >> (yet) since I am totally new to it (having moved over from Oracle). I >> just want to try it out and know it's stable for simple DML >> statements. >I do have a couple of patches that I haven't applied, due to not being >able to test them. One fixes alignment issues for OSF1, and the other >provides a fixed-point implementation for MONEY types. >I've asked if someone else wants to take over maintainership of the module >before, but with no responses. Where did you see the comments about >unapplied patches? unfortunately they were not forwarded to me. There are >fewer than ten people who have told me they are using the module. There >may be more lurkers. I honestly don't know who's using it. >Until I hear that someone else will maintain, I'll try to at least make >available the patches I get, even if I can't test them. hi peter, i use this module and can test patches (on solaris). i can maintain the module if you like, or just test patches for you (so the module can stay where it is). what do you want to do? raf From lixin.zhou@ariad.com Wed Sep 16 19:27:44 1998 From: lixin.zhou@ariad.com (Lixin Zhou) Date: Wed, 16 Sep 1998 14:27:44 -0400 Subject: [DB-SIG] oracledb and LONG Message-ID: <36000320.62D9B01E@ariad.com> I apologize if I am posting to a wrong group. How can I pull out the value of a LONG field using oracledb? What returns by cursor.fetchone or cursor.fetchall is always an empty string (not None). Thank you for your help. Lixin From gstein@lyra.org Wed Sep 16 22:51:57 1998 From: gstein@lyra.org (Greg Stein) Date: Wed, 16 Sep 1998 14:51:57 -0700 Subject: [DB-SIG] oracledb and LONG References: <36000320.62D9B01E@ariad.com> Message-ID: <360032FD.B5FFE59@lyra.org> Lixin Zhou wrote: > > I apologize if I am posting to a wrong group. > > How can I pull out the value of a LONG field using oracledb? What > returns by cursor.fetchone or cursor.fetchall is always an empty > string (not None). You should be getting back an object of type dbi.dbiRaw. The value of the long is in its "value" attribute. For example: row = cursor.fetchone() longval = row[0].value Hope that helps, -g -- Greg Stein (gstein@lyra.org) From grove@infotek.no Thu Sep 17 08:05:53 1998 From: grove@infotek.no (Geir Ove Gronmo) Date: Thu, 17 Sep 1998 09:05:53 +0200 Subject: [DB-SIG] oracledb and LONG In-Reply-To: <36000320.62D9B01E@ariad.com> Message-ID: <199809170704.JAA04790@mail.infotek.no> At 14:27 16.09.98 -0400, Lixin Zhou wrote: >How can I pull out the value of a LONG field using oracledb? What >returns by cursor.fetchone or cursor.fetchall is always an empty >string (not None). I've got the opposite problem. How can I insert a string or the content of a file (longer than 10Kb) into a LONG RAW field in the database using the oracledb module (0.1.3)? I've tried to use an ordinary insert statement -- and hexencoding the string, but I get an error message back from Oracle (ORA-1704 "string literal to long") when the document it longer than about 2000 characters. Could someone please help me out with this? All the best, Geir O. ================== Geir Ove Grønmo ================== | STEP Infotek as, Gjerdrumsvei 12, 0486 Oslo, Norway | | grove@infotek.no http://www.infotek.no/ | ------------------------------------------------------- From ageller@alumni.princeton.edu Thu Sep 17 20:39:25 1998 From: ageller@alumni.princeton.edu (Alan Geller) Date: Thu, 17 Sep 1998 15:39:25 -0400 Subject: [DB-SIG] RE: Re: [DB-SIG] oracledb and LONG Message-ID: <003e01bde272$e0b2b840$640563cf@b5k9k5> The only way I know of to insert (or update) a LONG or LONG RAW column in Oracle is to use a bind variable. Oracle won't handle a string literal longer than 2000 characters, regardless of the column data type. That is, sql = 'INSERT INTO TABLE_1 (COL_1) VALUES (:1)' cursor.execute(sql, (longVal, )) or a similar construct (the exact syntax depends on the Oracle Python interface you're using -- there are two, and I don't remember which is which). Note that longVal needs to be dbi.dbiRaw(longVal) if it's a LONG RAW column, and if you're using the dbi-compliant Oracle interface. As an aside, this is a good technique to use for data of any type; you can prepare the cursor once, and then execute it repeatedly with different data values. This avoids the (considerable) effort of repeatedly parsing the same SQL. Alan Geller ageller@alumni.princeton.edu -----Original Message----- From: Sent: None Subject: Message-Id: <199809170704.JAA04790@mail.infotek.no> Date: Thu, 17 Sep 1998 09:05:53 +0200 To: db-sig@python.org From: Geir Ove Gronmo Subject: Re: [DB-SIG] oracledb and LONG In-Reply-To: <36000320.62D9B01E@ariad.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit At 14:27 16.09.98 -0400, Lixin Zhou wrote: >How can I pull out the value of a LONG field using oracledb? What >returns by cursor.fetchone or cursor.fetchall is always an empty >string (not None). I've got the opposite problem. How can I insert a string or the content of a file (longer than 10Kb) into a LONG RAW field in the database using the oracledb module (0.1.3)? I've tried to use an ordinary insert statement -- and hexencoding the string, but I get an error message back from Oracle (ORA-1704 "string literal to long") when the document it longer than about 2000 characters. Could someone please help me out with this? All the best, Geir O. ================== Geir Ove Grønmo ================== | STEP Infotek as, Gjerdrumsvei 12, 0486 Oslo, Norway | | grove@infotek.no http://www.infotek.no/ | ------------------------------------------------------- From j.andrusaitis@konts.lv Fri Sep 18 12:49:44 1998 From: j.andrusaitis@konts.lv (Jekabs Andrusaitis) Date: Fri, 18 Sep 1998 14:49:44 +0300 Subject: [DB-SIG] RE: Re: [DB-SIG] oracledb and LONG Message-ID: <001701bde2fa$6d95b0f0$262a949f@jeecis.konts.lv> > sql = 'INSERT INTO TABLE_1 (COL_1) VALUES (:1)' > cursor.execute(sql, (longVal, )) I believe it is always a good idea to use bind variables. That way you dont have to worry about contents of string you want to insert. Jeekabs From grove@infotek.no Fri Sep 18 13:20:02 1998 From: grove@infotek.no (Geir Ove Gronmo) Date: Fri, 18 Sep 1998 14:20:02 +0200 Subject: [DB-SIG] RE: Re: [DB-SIG] oracledb and LONG In-Reply-To: <003e01bde272$e0b2b840$640563cf@b5k9k5> Message-ID: <199809181218.OAA23174@mail.infotek.no> At 15:39 17.09.98 -0400, you wrote: >The only way I know of to insert (or update) a LONG or LONG RAW column in >Oracle is to use a bind variable. Oracle won't handle a string literal longer >than 2000 characters, regardless of the column data type. > >That is, > > sql = 'INSERT INTO TABLE_1 (COL_1) VALUES (:1)' > cursor.execute(sql, (longVal, )) Great! This technique worked. I've tried using bind variables before, but unsuccessfully. I didn't realize that the second parameter of the execute method was supposed to be a tuple. Thanks a lot! Best regards, Geir O. ================== Geir Ove Grønmo ================== | STEP Infotek as, Gjerdrumsvei 12, 0486 Oslo, Norway | | grove@infotek.no http://www.infotek.no/ | ------------------------------------------------------- From Anthony Baxter Fri Sep 18 15:59:49 1998 From: Anthony Baxter (Anthony Baxter) Date: Sat, 19 Sep 1998 00:59:49 +1000 Subject: [DB-SIG] RE: Re: [DB-SIG] oracledb and LONG In-Reply-To: Your message of "Fri, 18 Sep 1998 14:49:44 +0300." <001701bde2fa$6d95b0f0$262a949f@jeecis.konts.lv> Message-ID: <199809181459.AAA24986@nara.off.connect.com.au> >>> "Jekabs Andrusaitis" wrote > > sql = 'INSERT INTO TABLE_1 (COL_1) VALUES (:1)' > > cursor.execute(sql, (longVal, )) > > I believe it is always a good idea to use bind variables. That way you dont > have to worry about contents of string you want to insert. It's also considerably more efficient - the database doesn't have to re-parse the SQL each time. Certainly in the case of Oracle, it caches the parsed SQL automatically. Anthony, trying to work out how to build a system that can handle 500 row inserts/second (sustained, over 24/7 :( From eb@tunes.com Fri Sep 18 21:25:41 1998 From: eb@tunes.com (Erik Bartels) Date: Fri, 18 Sep 1998 13:25:41 -0700 Subject: [DB-SIG] Unable to complete install of informixdb Message-ID: <003101bde342$81889300$63580ece@moose.tunesnetwork.com> I am trying to get the informixdb module working on Solaris 2.5 / Informix Version 7.20.UC2. I changed the LIBS definition in the Makefile to reflect the libraries listed by 'esql -libs'. Below is the output: eb@db3_13:00(~sasha/informix_db)make /usr/informix/bin/esql -e ifxdbmodule.ec gcc -g -DSTEP1 -DEXTENDED_ERROR_HANDLING -c ifxdbmodule.c -I/usr/informix/incl/esql -I/usr/local/include/python1.5 gcc -g -DSTEP1 -DEXTENDED_ERROR_HANDLING -c dbi.c -I/usr/informix/incl/esql -I/usr/local/include/python1.5 ld -G -o _informixdb.so -L/usr/informix/lib/esql -L/usr/informix/lib -lixsql -lixasf -lixgen -lixos -lixgls -lnsl -lsocket -laio -lm dbi.o -lixsql -lixasf -lixgen -lixos -lixgls -lnsl -lsocket -laio -lm -lixsq l -lixasf -lixgen -lixos -lixgls -lnsl -lsocket -laio -lm chmod 755 _informixdb.so eb@db3_13:00(~sasha/informix_db)python Python 1.5.1 (#1, Aug 10 1998, 16:16:20) [GCC 2.8.1] on sunos5 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import informixdb Traceback (innermost last): File "", line 1, in ? File "informixdb.py", line 16, in ? raise ImportError, "Cannot locate C core module for informix db interface." ImportError: Cannot locate C core module for informix db interface. >>> import _informixdb Traceback (innermost last): File "", line 1, in ? ImportError: ld.so.1: python: fatal: libixsql.so: open failed: No such file or directory >>> Any help is appreciated. Thanks, Erik Bartels eb@tunes.com From ucntcme@cyberhighway.net Fri Sep 18 23:07:16 1998 From: ucntcme@cyberhighway.net (Bill Anderson) Date: Fri, 18 Sep 1998 16:07:16 -0600 Subject: [DB-SIG] informixdb and RH 5.1 Message-ID: <3602D994.4CF1E272@cyberhighway.net> Has anyone got this combination to work? If so, how, precisely did you do it? (alos trying on a slackware Kernel 2.0.30 and 2.0.33 withno success, but that could wait a bit ..0 -- Bill Anderson Cyberhighway Internet Services, SYCON "Pluralitas non est ponenda sine neccesitate." Plurality should not be assumed without neccesity. From A.M.INGRALDI@larc.nasa.gov Mon Sep 21 13:24:57 1998 From: A.M.INGRALDI@larc.nasa.gov (Anthony M. Ingraldi) Date: Mon, 21 Sep 1998 08:24:57 -0400 Subject: [DB-SIG] Unable to complete install of informixdb In-Reply-To: <003101bde342$81889300$63580ece@moose.tunesnetwork.com> Message-ID: At 1:25 PM -0700 9/18/98, Erik Bartels wrote: >I am trying to get the informixdb module working on Solaris 2.5 / Informix >Version 7.20.UC2. > >I changed the LIBS definition in the Makefile to reflect the libraries >listed by 'esql -libs'. > >Below is the output: >... >ImportError: ld.so.1: python: fatal: libixsql.so: open failed: No such file >or directory Sounds like you need to set the INFORMIXDIR environment variable before you import the Informix module. -- Tony Ingraldi | e-mail: A.M.INGRALDI@LaRC.NASA.GOV NASA Langley Research Center | Mail Stop 267 | Phone : (757) 864-3039 Hampton, VA 23681-2199 | Fax : (757) 864-7892 From eb@tunes.com Mon Sep 21 23:32:37 1998 From: eb@tunes.com (Erik Bartels) Date: Mon, 21 Sep 1998 15:32:37 -0700 Subject: [DB-SIG] Unable to complete install of informixdb In-Reply-To: Message-ID: <005501bde5af$bc570920$63580ece@moose.tunesnetwork.com> > Sounds like you need to set the INFORMIXDIR environment variable > before you > import the Informix module. >>> import os >>> os.environ['INFORMIXDIR'] = '/usr/informix' >>> import informixdb Traceback (innermost last): File "", line 1, in ? File "informixdb.py", line 16, in ? raise ImportError, "Cannot locate C core module for informix db interface." ImportError: Cannot locate C core module for informix db interface. >>> import _informixdb Traceback (innermost last): File "", line 1, in ? ImportError: ld.so.1: python: fatal: libixsql.so: open failed: No such file or directory >>> Still not working. Any other ideas. Erik Bartels From sjturner@email.msn.com Tue Sep 22 00:59:44 1998 From: sjturner@email.msn.com (Stephen J. Turner) Date: Mon, 21 Sep 1998 19:59:44 -0400 Subject: [DB-SIG] Unable to complete install of informixdb Message-ID: <002801bde5bc$1160a280$010000c0@taran> On Monday, September 21, 1998 6:40 PM, Erik Bartels wrote: >>>> import os >>>> os.environ['INFORMIXDIR'] = '/usr/informix' >>>> import informixdb >Traceback (innermost last): > File "", line 1, in ? > File "informixdb.py", line 16, in ? > raise ImportError, "Cannot locate C core module for informix db interface." >ImportError: Cannot locate C core module for informix db interface. >>>> import _informixdb >Traceback (innermost last): > File "", line 1, in ? >ImportError: ld.so.1: python: fatal: libixsql.so: open failed: No such file or directory >>>> > >Still not working. Any other ideas. It sounds like the dynamic loader can't find the directories in which the Informix runtime libraries are installed. Be sure that $INFORMIXDIR/lib and $INFORMIXDIR/lib/esql are listed in the LD_LIBRARY_PATH environment variable. - sturner From eb@tunes.com Tue Sep 22 22:42:16 1998 From: eb@tunes.com (Erik Bartels) Date: Tue, 22 Sep 1998 14:42:16 -0700 Subject: [DB-SIG] Unable to complete install of informixdb In-Reply-To: Message-ID: <001f01bde671$ddb288c0$63580ece@moose.tunesnetwork.com> eb@db3_13:07(~sasha/informix_db)make clean ; make rm -rf *.so *.o ifxdbmodule.c /usr/informix/bin/esql -e ifxdbmodule.ec gcc -g -DSTEP1 -DEXTENDED_ERROR_HANDLING -c ifxdbmodule.c -I/usr/informix/incl/esql -I/usr/local/include/python1.5 gcc -g -DSTEP1 -DEXTENDED_ERROR_HANDLING -c dbi.c -I/usr/informix/incl/esql -I/usr/local/include/python1.5 ld -G -o _informixdb.so -L/usr/informix/lib -L/usr/informix/lib/esql -R/usr/informix /lib/esql -R/usr/informix/lib -lixsql -lixasf -lixgen -lixos -lixgls -lnsl - lsocket -laio -lm dbi.o -lixsql -lixasf -lixgen -lixos -lixgls -lnsl -lsocket -laio -lm -lixsq l -lixasf -lixgen -lixos -lixgls -lnsl -lsocket -laio -lm chmod 755 _informixdb.so eb@db3_13:07(~sasha/informix_db)python Python 1.5.1 (#1, Aug 10 1998, 16:16:20) [GCC 2.8.1] on sunos5 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import _informixdb Traceback (innermost last): File "", line 1, in ? ImportError: ld.so.1: python: fatal: relocation error: file /usr/informix/lib/esql/libixsql.so: symbol ifx_checkAPI: referenced symbol not foun LIBDIRS= -L${INFORMIXDIR}/lib -L${INFORMIXDIR}/lib/esql -R${INFORMIXDIR}/lib /esql -R${INFORMIXDIR}/lib Adding the run time library search path (-R) results in the above error. Am I heading in the right direction? > -----Original Message----- > From: Anthony M. Ingraldi [mailto:a.m.ingraldi@larc.nasa.gov] > Sent: Monday, September 21, 1998 6:47 PM > To: eb@tunes.com > Subject: RE: [DB-SIG] Unable to complete install of informixdb > > > Erik, > > > > >Still not working. Any other ideas. > > > > > > What options are you linking the informix module with? On the Solaris > system that I run on, I used the -R option with ld to specify the library > search path. Alternatively (I think), you could define LD_LIBRARY_PATH to > include the location of the informix libraries. > > Sorry about the previous dead-end advice. > > -- > Tony Ingraldi e-mail: > A.M.INGRALDI@LaRC.NASA.GOV > NASA Langley Research Center > Mail Stop 267 Phone : (757) 864-3039 > Hampton, VA 23681-0001 Fax : (757) 864-7892 > > > From ray@unival.com Wed Sep 23 19:09:44 1998 From: ray@unival.com (ray@unival.com) Date: Wed, 23 Sep 1998 11:09:44 -0700 Subject: [DB-SIG] Where is latest informix module? Message-ID: <88256688.006393F9.00@bilbo.collegenet.com> I just downloaded release 1.01 dated 1997-03-11 from www.python.org I know there is a later version, but where? Ray From alexan@unicorn.micex.ru Thu Sep 24 06:46:58 1998 From: alexan@unicorn.micex.ru (Alexander Kuznetsov) Date: Thu, 24 Sep 1998 09:46:58 +0400 Subject: [DB-SIG] Where is latest informix module? References: <88256688.006393F9.00@bilbo.collegenet.com> Message-ID: <3609DCD2.AF6BED06@unicorn.micex.ru> ray@unival.com wrote:
I just downloaded release 1.01 dated 1997-03-11 from www.python.org
I know there is a later version, but where?
I wrote a completely new informix module. It's called Kinfxdb.
Avaliable here
          http://thor.prohosting.com/~alexan/pub/Kinfxdb/Kinfxdb-0.2.tar.gz
New version is aproaching...
-- 
Alexander Kuznetsov, alexan@unicorn.micex.ru
  From arb@connect.com.au Tue Sep 29 02:12:57 1998 From: arb@connect.com.au (Anthony Baxter) Date: Tue, 29 Sep 1998 11:12:57 +1000 Subject: [DB-SIG] :1 vs. :arg variables in SQL (oracle interface). Message-ID: <199809290112.LAA14810@koro.off.connect.com.au> I'm working my way through the oracle interface, adding the bits I need. Right now I'm looking at the insert of multiple rows - from the OCI manuals I have, it looks like the only way to do these are with obindps(). obindps() only supports the :name form of variables, not positional ones. This is a problem. Looking at the DC guys' documentation, they chose to fix this by breaking backwards compatibility - you have to use :p1 instead of :1, &c. I'd prefer not to have to do this, but I'm at a bit of a loss as to what else to do. Anyone? Anthony From harri.pasanen@trema.com Tue Sep 29 09:05:57 1998 From: harri.pasanen@trema.com (Harri Pasanen) Date: Tue, 29 Sep 1998 10:05:57 +0200 Subject: [DB-SIG] Sybase module - Free Sybase for Linux Message-ID: <361094E5.2F6B78AD@trema.com> Just in case this passed unnoticed by someone: There is now a free Adaptive Server Enterprise for Linux available (Sybase server) Check out: http://www.sybase.com/adaptiveserver/linux/ --Harri From jim.fulton@Digicool.com Tue Sep 29 11:33:26 1998 From: jim.fulton@Digicool.com (Jim Fulton) Date: Tue, 29 Sep 1998 06:33:26 -0400 Subject: [DB-SIG] :1 vs. :arg variables in SQL (oracle interface). References: <199809290112.LAA14810@koro.off.connect.com.au> Message-ID: <3610B776.5C890E70@digicool.com> Anthony Baxter wrote: > > I'm working my way through the oracle interface, adding the bits I need. > > Right now I'm looking at the insert of multiple rows - from the OCI manuals > I have, it looks like the only way to do these are with obindps(). obindps() > only supports the :name form of variables, not positional ones. This is > a problem. > > Looking at the DC guys' documentation, they chose to fix this by breaking > backwards compatibility - How so? Backward compatible with what? DCOracle doesn't try (or even want;) to be backward compatible with oracledb. We were only striving for compatability with the DB-API. The DB-API documentation seems pretty liberal on this to me. (Actually, it is too liberal, IMO. I think it should specify a database-independent syntax.) > you have to use :p1 instead of :1, &c. I'd prefer > not to have to do this, but I'm at a bit of a loss as to what else to do. You could write a preprocessor to scan the SQL for :1 and transform it to something like :p1. We may do this eventually. Jim -- Jim Fulton mailto:jim@digicool.com Technical Director (888) 344-4332 Python Powered! Digital Creations http://www.digicool.com http://www.python.org Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email address may not be added to any commercial mail list with out my permission. Violation of my privacy with advertising or SPAM will result in a suit for a MINIMUM of $500 damages/incident, $1500 for repeats. From Anthony Baxter Tue Sep 29 12:09:52 1998 From: Anthony Baxter (Anthony Baxter) Date: Tue, 29 Sep 1998 21:09:52 +1000 Subject: [DB-SIG] :1 vs. :arg variables in SQL (oracle interface). In-Reply-To: Your message of "Tue, 29 Sep 1998 06:33:26 -0400." <3610B776.5C890E70@digicool.com> References: <3610B776.5C890E70@digicool.com> <199809290112.LAA14810@koro.off.connect.com.au> Message-ID: <199809291109.VAA02086@koro.off.connect.com.au> >>> Jim Fulton wrote > > Looking at the DC guys' documentation, they chose to fix this by breaking > > backwards compatibility - > > How so? Backward compatible with what? DCOracle doesn't > try (or even want;) to be backward compatible with oracledb. Ok, so poor choice of words on my part. Since this _is_ on oracledb, I'm trying to not break backwards compat. A twist I want to try out is whether oracle allows named parameters called ':1', ':2' and so on. If so, end of problem. > > you have to use :p1 instead of :1, &c. I'd prefer > > not to have to do this, but I'm at a bit of a loss as to what else to do. > > You could write a preprocessor to scan the SQL for :1 and transform it > to something like :p1. We may do this eventually. Strangely, the thought of writing an SQL parser makes me twitch. Anthony From jim.fulton@Digicool.com Tue Sep 29 12:37:34 1998 From: jim.fulton@Digicool.com (Jim Fulton) Date: Tue, 29 Sep 1998 07:37:34 -0400 Subject: [DB-SIG] :1 vs. :arg variables in SQL (oracle interface). References: <3610B776.5C890E70@digicool.com> <199809290112.LAA14810@koro.off.connect.com.au> <199809291109.VAA02086@koro.off.connect.com.au> Message-ID: <3610C67E.5FB01C86@digicool.com> Anthony Baxter wrote: > > Strangely, the thought of writing an SQL parser makes me twitch. I don't think you actually need to write a full parser. All you have to worry about is not messing with ":1" that might be buried in a string literal. Right? Further, the rules for SQL string literals make this pretty easy to avoid. Something along the lines of (a better algorithm, avoiding regsub should be used): ssql=string.split(sql,"'") for i in range(0,2,len(ssql)): ssql[i]=regsub.gsub(':\([0-9]+\)',':p\\1',ssql[i]) sql=string.join(sql,"'") should work fine. No? Can you think of any Oracle SQL that would defeat this? Jim -- Jim Fulton mailto:jim@digicool.com Technical Director (888) 344-4332 Python Powered! Digital Creations http://www.digicool.com http://www.python.org Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email address may not be added to any commercial mail list with out my permission. Violation of my privacy with advertising or SPAM will result in a suit for a MINIMUM of $500 damages/incident, $1500 for repeats. From gstein@lyra.org Tue Sep 29 13:20:14 1998 From: gstein@lyra.org (Greg Stein) Date: Tue, 29 Sep 1998 05:20:14 -0700 Subject: [DB-SIG] :1 vs. :arg variables in SQL (oracle interface). References: <3610B776.5C890E70@digicool.com> <199809290112.LAA14810@koro.off.connect.com.au> <199809291109.VAA02086@koro.off.connect.com.au> <3610C67E.5FB01C86@digicool.com> Message-ID: <3610D07E.4C7DEA36@lyra.org> Jim Fulton wrote: > > Anthony Baxter wrote: > > > > Strangely, the thought of writing an SQL parser makes me twitch. > > I don't think you actually need to write a full parser. All you > have to worry about is not messing with ":1" that might be buried > in a string literal. Right? Further, the rules for SQL string literals > make this pretty easy to avoid. Agreed. > Something along the lines of (a better algorithm, > avoiding regsub should be used): > > ssql=string.split(sql,"'") > for i in range(0,2,len(ssql)): > ssql[i]=regsub.gsub(':\([0-9]+\)',':p\\1',ssql[i]) > sql=string.join(sql,"'") > > should work fine. No? Can you think of any Oracle SQL that > would defeat this? A simple parser to convert :1 syntax to ? syntax for ODBC was written as part of the Win32 ODBC module. You may be able to adapt this to the desired behavior. Just call it repeatedly, and it returns characters for your resulting SQL text (original, or translated). It also performs a bit of bookkeeping because if :1 appears twice, then the caller has to bind one of the inputs twice (once for each resulting '?'). Cheers, -g static char doParse(parseContext *ct) { ct->isParm = 0; if (ct->state == *ct->ptr) { ct->state = 0; } else if (ct->state == 0){ if ((*ct->ptr == '\'') || (*ct->ptr == '"')) { ct->state = *ct->ptr; } else if (*ct->ptr == '?') { ct->parmIdx = ct->parmCount; ct->parmCount++; ct->isParm = 1; } else if ((*ct->ptr == ':') && !isalnum(ct->prev)) { const char *m = ct->ptr + 1; int n = 0; while (isdigit(*m)) { n *= 10; n += *m - '0'; m++; } if (n) { ct->parmIdx = n-1; ct->parmCount++; ct->ptr = m; ct->isParm = 1; ct->prev = '0'; return '?'; } } } ct->prev = *ct->ptr; return *ct->ptr++; } -- Greg Stein (gstein@lyra.org) From pgodman@halcyon.com Tue Sep 29 18:46:25 1998 From: pgodman@halcyon.com (Peter Godman) Date: Tue, 29 Sep 1998 10:46:25 -0700 (PDT) Subject: [DB-SIG] Re: Sybase module In-Reply-To: <199809160151.LAA03896@mali.comdyn.com.au> Message-ID: On Wed, 16 Sep 1998, raf wrote: > hi peter, > > i use this module and can test patches (on solaris). > i can maintain the module if you like, or just test > patches for you (so the module can stay where it is). > what do you want to do? > > raf > Hey everyone. Well, I don't know if you guys heard the news or not, but Sybase has made ASE (adaptive server enterprise?) freely available (without support) for linux. I think it's pretty incredible, and will mean I can maintain the module once more. I'm going to apply the patches I have first, and make a release. Has anyone considered a cross-dbapi test suite that tests modules to the spec? I know that the spec is considered just a suggestion, but it would be nice if there were a minimum set of functionality that every module provided, with standard exceptions raised for unimplemented / nonstandard behaviour. Cheers Pete From akuchlin@cnri.reston.va.us Tue Sep 29 19:51:55 1998 From: akuchlin@cnri.reston.va.us (Andrew M. Kuchling) Date: Tue, 29 Sep 1998 14:51:55 -0400 (EDT) Subject: [DB-SIG] Re: Sybase module In-Reply-To: References: <199809160151.LAA03896@mali.comdyn.com.au> Message-ID: <13841.9095.942555.863690@amarok.cnri.reston.va.us> Peter Godman writes: >Has anyone considered a cross-dbapi test suite that tests modules to the >spec? I know that the spec is considered just a suggestion, but it would >be nice if there were a minimum set of functionality that every module >provided, with standard exceptions raised for unimplemented / nonstandard >behaviour. That would definitely be a good idea, since it would probably shake out a whole bunch of incompatibilities among the different modules. I contemplated writing a test suite when I was working on an article about the DB-API, but never got around to doing so. -- A.M. Kuchling http://starship.skyport.net/crew/amk/ As soon as Roger saw the costume, his mind assumed the proportions of an industrial revolution unaware of the ecological damage it was causing. -- The origin of the Head, in ENIGMA #1: "The Lizard, The Head, The Enigma"