From lalvarez at novamens.com Tue Nov 1 18:23:39 2005 From: lalvarez at novamens.com (Lucas Alvarez) Date: Tue, 01 Nov 2005 14:23:39 -0300 Subject: [DB-SIG] External procedure Message-ID: <4367A49B.5020008@novamens.com> Hi All, I want to create a trigger that runs a python script, is that possible? I'm using oracle 9i. I would appreciate any help, thanks in advance. Lucas Alvarez From mal at egenix.com Tue Nov 1 22:17:15 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue, 01 Nov 2005 22:17:15 +0100 Subject: [DB-SIG] External procedure In-Reply-To: <4367A49B.5020008@novamens.com> References: <4367A49B.5020008@novamens.com> Message-ID: <4367DB5B.3040309@egenix.com> Lucas Alvarez wrote: > Hi All, > I want to create a trigger that runs a python script, is that possible? > I'm using oracle 9i. > I would appreciate any help, thanks in advance. This depends on the Oracle implementation of stored procedures, not on Python (which this list is all about). I know that Oracle can run Java code as stored procedure, so you might be able to use Jython to run Python code indirectly. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Nov 01 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From mscott at goldenspud.com Wed Nov 2 19:14:22 2005 From: mscott at goldenspud.com (Matthew Scott) Date: Wed, 2 Nov 2005 12:14:22 -0600 Subject: [DB-SIG] ANN: Schevo 3.0-beta1 released Message-ID: ================== Schevo 3.0-beta1 ================== ---------------------- Release Announcement ---------------------- Also available at http://schevo.org/latest/release/announcements/3.0-beta1.html What's new in version 3.0-beta1? ================================ * Initial release of Schevo 3.0 series. Get Schevo! =========== See the `Schevo website`_ for more information, or go ahead and `get started with Schevo`_. .. _Schevo website: http://schevo.org/ .. _get started with Schevo: http://schevo.org/latest/guides/getting-started.html What is Schevo? =============== Schevo is a next-generation DBMS that focuses on the following: - **Database Integrity**: Schevo is designed from the ground up to protect your data. All changes to a Schevo database must be done using transactions, and Schevo ensures that those transactions always leave the database in a consistent state. - **Rapid Development**: Schevo includes features to make it easy and fun to create even the most complex of databases. Not only is the schema syntax easy to write and understand, you can also quickly place initial values in your schema that are required by your database, and use the same syntax to create sets of sample data to use during development. - **User Interface Generation**: Schevo provides user interface toolkits that take advantage of the richness of the database schema. You can use the full-featured Schevo Navigator to interact with your database without writing a single line of code outside of your database schema. A PyQt-based toolkit is already available, and TurboGears and NuFox toolkits are in the works. - **Rich Schema Definition**: The schema for a Schevo database is written in concise, easy-to-read Python code. Not only does the schema describe how information in the database is structured, but also defines all transactions and rules that ensure database integrity. - **Assisted Schema Evolution**: Once a Schevo database is deployed and is used to store valuable data, you will inevitably make further changes to the structure of the database. Schevo assists you in this task and makes it easy to restructure a database and facilitate the migration of data from one schema version to the next. Why use Schevo? =============== The main problem that Schevo was designed to address is that Relational databases, which use Structured Query Language (SQL), do not match well with object-oriented programming languages, such as Java, Python and Ruby. This situation has been labeled the "object-relational impedance mismatch" problem, and it is a significant barrier to the rapid development and evolution of database applications. Because of this mismatch, database applications tend to have three distinct layers of code: SQL within the database, object-oriented code within the application, and an object-relational mapping (ORM) layer to mediate between the SQL and the object language. These extra layers add additional complexity and inflexibility to what are already complex and inflexible databases. Schevo eliminates these extra layers. Schevo solves the object-relational impedance mismatch problem by combining relational features with the object-oriented programming language Python. A database schema defined in Schevo results in a database that enforces the same integrity constraints supported by the Relational model, with the added benefit of Python objects. The benefit of this is that application developers can create their entire application using the full power of the Python language without having to introduce another language (SQL) that has its own language constructs, its own datatypes, and a limited set of behavior. Instead, a Schevo database stores Schevo objects which use native Python datatypes and include any behavior defined for those objects. In addition, Schevo objects contain a great deal of metadata that is available for introspection to support the development of rich user interfaces with a minimal amount of code. In fact, Schevo includes a GUI Navigator that can display a fully interactive interface into any Schevo database. The Navigator is constructed on-the-fly based solely on the metadata available within the Schevo database file. The Navigator allows you to display, create, update, and delete any object within the database, within the rules and constraints defined for that database. -- Matthew R. Scott From csotelop at yahoo.es Sat Nov 5 15:28:05 2005 From: csotelop at yahoo.es (Carlos Eduardo Sotelo Pinto) Date: Sat, 05 Nov 2005 09:28:05 -0500 Subject: [DB-SIG] Foxpro In-Reply-To: References: Message-ID: <436CC175.5020707@yahoo.es> hi.. i have done a dbf connection... i used adodbapi for conecctiong dbf files... i hope it will be useful for you http://www.connectionstrings.com/ Daniel Bowett wrote: > Hi all, > > I've been programming with python for a while now. Recently I switched > to Linux but can't find a way to read and update Foxpro dbf's. > > In windows I would have done a ODBC connection. > > Can anyone help? > > Regards, > > Dan. > > _______________________________________________ > DB-SIG maillist - DB-SIG at python.org > http://mail.python.org/mailman/listinfo/db-sig > ______________________________________________ Renovamos el Correo Yahoo! Nuevos servicios, más seguridad http://correo.yahoo.es From matthew.williams at cancer.org.uk Tue Nov 8 21:36:30 2005 From: matthew.williams at cancer.org.uk (Matt Williams) Date: Tue, 08 Nov 2005 20:36:30 +0000 Subject: [DB-SIG] Pycon2005-attendees (ontology f/up) In-Reply-To: 4245EC79.5020205@comcast.net Message-ID: <1131482190.2747.38.camel@localhost.localdomain> Long delay I know, but on Sunday Mar 27th, Lloyd Kvam mentioned he had some python ontology modules that he would consider releasing if interested.... I'm interested. Matt -- Dr. M. Williams MRCP(UK) Clinical Research Fellow Cancer Research UK +44 (0)207 269 2953 +44 (0)7834 899570 http://acl.icnet.uk/~mw http://adhominem.blogspot.com From python at venix.com Wed Nov 9 13:44:05 2005 From: python at venix.com (Python) Date: Wed, 09 Nov 2005 07:44:05 -0500 Subject: [DB-SIG] Pycon2005-attendees (ontology f/up) In-Reply-To: <1131482190.2747.38.camel@localhost.localdomain> References: <1131482190.2747.38.camel@localhost.localdomain> Message-ID: <1131540245.5479.104.camel@www.venix.com> Unfortunately, I was passing on an email from Stephen Waterbury http://mail.python.org/pipermail/pycon2005-attendees/2005-March/000073.html and do not have the ontology modules myself. On Tue, 2005-11-08 at 20:36 +0000, Matt Williams wrote: > Long delay I know, but on Sunday Mar 27th, Lloyd Kvam mentioned he had > some python ontology modules that he would consider releasing if > interested.... > > I'm interested. > > Matt -- Lloyd Kvam Venix Corp From andy47 at halfcooked.com Fri Nov 11 09:15:04 2005 From: andy47 at halfcooked.com (Andy Todd) Date: Fri, 11 Nov 2005 19:15:04 +1100 Subject: [DB-SIG] External procedure In-Reply-To: <4367A49B.5020008@novamens.com> References: <4367A49B.5020008@novamens.com> Message-ID: <43745308.2050806@halfcooked.com> Lucas Alvarez wrote: > Hi All, > I want to create a trigger that runs a python script, is that possible? > I'm using oracle 9i. > I would appreciate any help, thanks in advance. > > Lucas Alvarez > > _______________________________________________ > DB-SIG maillist - DB-SIG at python.org > http://mail.python.org/mailman/listinfo/db-sig Oracle stored procedures can be developed in either PL/SQL or Java. That's about it I'm afraid. You can, of course, write Python programs that access Oracle databases but sadly there is currently no way of making them run natively in the database. As Marc-Andre suggested you could think about developing your code in Jython but it would have to be turned into Java bytecode before you loaded it into Oracle, which rather defeats the purpose I fear. Although, correcting myself, if you want to upgrade to Oracle 10.2 and only run on Windows you can develop stored procedures in any language that runs on the CLR; http://www.oracle.com/technology/pub/articles/mastering_dotnet_oracle/williams_sps.html Regards, Andy -- -------------------------------------------------------------------------------- From the desk of Andrew J Todd esq - http://www.halfcooked.com/ From python at dabrado.net Sat Nov 12 13:09:28 2005 From: python at dabrado.net (Braden) Date: Sat, 12 Nov 2005 04:09:28 -0800 Subject: [DB-SIG] DB-API and 'COPY table FROM STDIN' Message-ID: <1406D793-A045-44A7-BC13-4A9388F2999A@dabrado.net> Hello, I'm a bit new to database stuff, so I'm sorry if this question has an easily discoverable answer. Basically I wanted to know, when using the DB API, is it possible to execute a 'COPY table FROM STDIN' command? If so, where would stdin be in this case? I.e., where would one send the data? If this isn't possible, is there some similar way to dump a lot of data into a table when using the DB API? Is the closest thing using a cursor's 'executemany' method with an 'INSERT' command? Thanks for any help! - Braden From fog at initd.org Sat Nov 12 14:41:17 2005 From: fog at initd.org (Federico Di Gregorio) Date: Sat, 12 Nov 2005 14:41:17 +0100 Subject: [DB-SIG] DB-API and 'COPY table FROM STDIN' In-Reply-To: <1406D793-A045-44A7-BC13-4A9388F2999A@dabrado.net> References: <1406D793-A045-44A7-BC13-4A9388F2999A@dabrado.net> Message-ID: <1131802877.5272.1.camel@localhost> Il giorno sab, 12/11/2005 alle 04.09 -0800, Braden ha scritto: > Hello, > > I'm a bit new to database stuff, so I'm sorry if this question has > an easily discoverable answer. > > Basically I wanted to know, when using the DB API, is it possible > to execute a 'COPY table FROM STDIN' command? If so, where would > stdin be in this case? I.e., where would one send the data? COPY is not part of the DBAPI. Some drivers, like psycopg, offer some kind of support for it but it is driver-dependent. federico -- Federico Di Gregorio http://people.initd.org/fog Debian GNU/Linux Developer fog at debian.org INIT.D Developer fog at initd.org You should use @literal, but you should have the grace to be embarrassed. -- Norman Ramsey -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: This is a digitally signed message part Url : http://mail.python.org/pipermail/db-sig/attachments/20051112/01393675/attachment.pgp From tod_haren at yahoo.com Wed Nov 16 00:58:26 2005 From: tod_haren at yahoo.com (Tod Haren) Date: Tue, 15 Nov 2005 15:58:26 -0800 (PST) Subject: [DB-SIG] ADOCE with PythonCE Message-ID: <20051115235826.56829.qmail@web84111.mail.dcn.yahoo.com> I've posted this to the PythonCE list as well. I'm looking for info on accessing ADOCE on the Pocket PC. I'd like to use Python instead of VBScript. I've found several example on using ADODB for the desktop, but nothing for the PPC. I'm not stuck on ADOCE, so any other methods for accessing the Pocket Access (.cdb) or MS SQL CE database formats. Actually any documentation on any relational DB on the Pocket PC with Python would be helpful. Thanks From Chris.Clark at ca.com Wed Nov 16 01:14:49 2005 From: Chris.Clark at ca.com (Clark, Chris M) Date: Tue, 15 Nov 2005 19:14:49 -0500 Subject: [DB-SIG] ADOCE with PythonCE Message-ID: <5F0EF692A76C0F4D970C00F5D5B3445F02DEFDB3@usilms28.ca.com> > -----Original Message----- > From: db-sig-bounces at python.org > [mailto:db-sig-bounces at python.org] On Behalf Of Tod Haren > Sent: Tuesday, November 15, 2005 3:58 PM > To: db-sig at python.org > Subject: [DB-SIG] ADOCE with PythonCE > > I've posted this to the PythonCE list as well. > > I'm looking for info on accessing ADOCE on the Pocket PC. > I'd like to use Python instead of VBScript. I've found > several example on using ADODB for the desktop, but nothing > for the PPC. > > I'm not stuck on ADOCE, so any other methods for accessing > the Pocket Access (.cdb) or MS SQL CE database formats. > I think you are out of luck with respect to Microsoft databases, sorry :-( I'd like to be proved wrong though. > Actually any documentation on any relational DB on the Pocket > PC with Python would be helpful. > I'm using pysqlite - I got it (and the URL) from the PythonCE archives. I think I'm using this one http://mail.python.org/pipermail/pythonce/2004-September/000730.html I'm running a mini-web server on my pda and use PocketIE (and/or ftx) as the "gui" - example on the desktop here http://yacddb.sourceforge.net/ none of my xml resource files for wxWindows work on my handheld, hence the low tech UI Chris From carsten at uniqsys.com Mon Nov 21 06:33:53 2005 From: carsten at uniqsys.com (Carsten Haese) Date: Mon, 21 Nov 2005 00:33:53 -0500 Subject: [DB-SIG] [ANN] Python API InformixDB-2.1 released Message-ID: <20051121051235.M439@uniqsys.com> Hi everybody: I am proud to announce a new release of InformixDB, the IBM Informix implementation of the Python DB API. This release adds the following new features: * Scroll cursors and cursors with hold * Support for INTERVAL types * Support for Smart Large Objects * Support for User Defined Types Downloads and more info at http://informixdb.sourceforge.net/ Enjoy, Carsten Haese. From marco_paolini at yahoo.com Thu Nov 24 21:10:06 2005 From: marco_paolini at yahoo.com (marco paolini) Date: Thu, 24 Nov 2005 12:10:06 -0800 (PST) Subject: [DB-SIG] PyJdbc released Message-ID: <20051124201006.33273.qmail@web35508.mail.mud.yahoo.com> Hello everybody, I have released the first (beta) version of pyjdbc. It is a DB driver that allows python programs to communicate with databases through java JDBC drivers. It is Free Software and it is available on the SourceForge site at http://pyjdbc.sf.net . Please note that release 0.1 is neither stable nor complete. It has been tested on linux, mac and win. Let me know if it is of your taste, Bye, Marco Paolini __________________________________ Yahoo! Music Unlimited Access over 1 million songs. Try it free. http://music.yahoo.com/unlimited/ From mal at egenix.com Thu Nov 24 21:47:17 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu, 24 Nov 2005 21:47:17 +0100 Subject: [DB-SIG] PyJdbc released In-Reply-To: <20051124201006.33273.qmail@web35508.mail.mud.yahoo.com> References: <20051124201006.33273.qmail@web35508.mail.mud.yahoo.com> Message-ID: <438626D5.2050406@egenix.com> marco paolini wrote: > Hello everybody, > > I have released the first (beta) version of pyjdbc. > > It is a DB driver that allows python programs to > communicate with databases through java JDBC drivers. > > It is Free Software and it is available on the > SourceForge site at http://pyjdbc.sf.net . > > Please note that release 0.1 is neither stable nor > complete. It has been tested on linux, mac and win. > > Let me know if it is of your taste, I wonder whether you are aware of zxJDBC, which has been around for years and is distributed under the Jython license: http://www.ziclix.com/zxjdbc/ -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Nov 24 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From marco_paolini at yahoo.com Fri Nov 25 00:25:55 2005 From: marco_paolini at yahoo.com (marco paolini) Date: Thu, 24 Nov 2005 15:25:55 -0800 (PST) Subject: [DB-SIG] PyJdbc released Message-ID: <20051124232555.69340.qmail@web35511.mail.mud.yahoo.com> I am aware of it. zxJDBC works on Jython while PyJdbc works on CPython. I will put some documentation on the SF site (http://sf.net/projects/pyjdbc) about PyJdbc architecture. In few words: There is the python library, that binds to Ice (http://zeroc.com) and on the other side of the web cloud there is the java server that binds with the jdbc driver you choose. They are two different processes that can also run on different boxes. By the way, tommorrow I will put up a new more usable release. > > --- "M.-A. Lemburg" wrote: > > > marco paolini wrote: > > > Hello everybody, > > > > > > I have released the first (beta) version of > > pyjdbc. > > > > > > It is a DB driver that allows python programs to > > > communicate with databases through java JDBC > > drivers. > > > > > > It is Free Software and it is available on the > > > SourceForge site at http://pyjdbc.sf.net . > > > > > > Please note that release 0.1 is neither stable > nor > > > complete. It has been tested on linux, mac and > > win. > > > > > > Let me know if it is of your taste, > > > > I wonder whether you are aware of zxJDBC, > > which has been around for years and is distributed > > under the Jython license: > > > > http://www.ziclix.com/zxjdbc/ > > > > -- > > Marc-Andre Lemburg > > eGenix.com > > > > Professional Python Services directly from the > > Source (#1, Nov 24 2005) > > >>> Python/Zope Consulting and Support ... > > http://www.egenix.com/ > > >>> mxODBC.Zope.Database.Adapter ... > > http://zope.egenix.com/ > > >>> mxODBC, mxDateTime, mxTextTools ... > > http://python.egenix.com/ > > > ________________________________________________________________________ > > > > ::: Try mxODBC.Zope.DA for > > Windows,Linux,Solaris,FreeBSD for free ! :::: > > > > > > > __________________________________ > Yahoo! Music Unlimited > Access over 1 million songs. Try it free. > http://music.yahoo.com/unlimited/ > __________________________________ Yahoo! Mail - PC Magazine Editors' Choice 2005 http://mail.yahoo.com From carsten at uniqsys.com Mon Nov 28 16:40:29 2005 From: carsten at uniqsys.com (Carsten Haese) Date: Mon, 28 Nov 2005 10:40:29 -0500 Subject: [DB-SIG] Accepted method for handling decimals? Message-ID: <1133192429.24405.30.camel@dot.uniqsys.com> Hi everybody: I am planning to implement support for decimals in InformixDB (http://informixdb.sourceforge.net) using the python decimal module if it's available. My question is, should fetches simply return Decimal instances instead of floats, or should there be some kind of configuration setting to choose whether to return floats or Decimals? If so, on what level should that setting reside, module, connection, or cursor? I am leaning towards providing an optional argument to the Cursor() constructor for turning on Decimal handling, and by default the cursor would return floats. My reasoning here is that returning Decimals would incur a (small) performance penalty that the user should only have to pay if they need the precision that using Decimals gives them. As far as the name of this optional argument, I'm considering "use_decimal", but I'm open to suggestions. Comments are welcome. Best regards, Carsten Haese. From fog at initd.org Mon Nov 28 17:21:52 2005 From: fog at initd.org (Federico Di Gregorio) Date: Mon, 28 Nov 2005 17:21:52 +0100 Subject: [DB-SIG] Accepted method for handling decimals? In-Reply-To: <1133192429.24405.30.camel@dot.uniqsys.com> References: <1133192429.24405.30.camel@dot.uniqsys.com> Message-ID: <1133194912.4247.32.camel@localhost> Il giorno lun, 28/11/2005 alle 10.40 -0500, Carsten Haese ha scritto: > Hi everybody: > > I am planning to implement support for decimals in InformixDB > (http://informixdb.sourceforge.net) using the python decimal module if > it's available. My question is, should fetches simply return Decimal > instances instead of floats, or should there be some kind of > configuration setting to choose whether to return floats or Decimals? If > so, on what level should that setting reside, module, connection, or > cursor? I'd return decimals by default (actually psycopg 2 does.) If the programmer uses a money or decimal column then it probably does not want the rouding errors of float point numbers. He will be more than happy to incur in a small performance penalty to have "exact" numbers. About the configuration, psycopg just allow the programmer to override any of the default "type caster" functions with a user-defined one. Really usefull. federico -- Federico Di Gregorio http://people.initd.org/fog Debian GNU/Linux Developer fog at debian.org INIT.D Developer fog at initd.org Su grappe nessuno ? innocente. -- Natale Titotto -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: Questa parte del messaggio =?ISO-8859-1?Q?=E8?= firmata Url : http://mail.python.org/pipermail/db-sig/attachments/20051128/93c44ef7/attachment.pgp From mal at egenix.com Mon Nov 28 22:59:40 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon, 28 Nov 2005 22:59:40 +0100 Subject: [DB-SIG] Accepted method for handling decimals? In-Reply-To: <1133192429.24405.30.camel@dot.uniqsys.com> References: <1133192429.24405.30.camel@dot.uniqsys.com> Message-ID: <438B7DCC.1030204@egenix.com> Carsten Haese wrote: > Hi everybody: > > I am planning to implement support for decimals in InformixDB > (http://informixdb.sourceforge.net) using the python decimal module if > it's available. My question is, should fetches simply return Decimal > instances instead of floats, or should there be some kind of > configuration setting to choose whether to return floats or Decimals? If > so, on what level should that setting reside, module, connection, or > cursor? It is usually a good idea to have such attributes on connections and cursors - cursors then inherit the setting from the connection at the time they are created. This allows the user to customize the behavior at a connection or cursor level, as needed. > I am leaning towards providing an optional argument to the Cursor() > constructor for turning on Decimal handling, and by default the cursor > would return floats. My reasoning here is that returning Decimals would > incur a (small) performance penalty that the user should only have to > pay if they need the precision that using Decimals gives them. As far as > the name of this optional argument, I'm considering "use_decimal", but > I'm open to suggestions. .cursor() normally doesn't take any arguments. I think the better way is to introduce settable attributes to connection and cursor objects, e.g. .decimalformat having values 'float' or 'decimal'. mxODBC uses the attributes .datetimeformat and .stringformat for such customizations: http://www.egenix.com/files/python/mxODBC.html#Cursors However, in general, I think that we should come up with an easy to use way to map database types to Python constructors. One which is flexible enough to set these mappings on a per-cursor and even per-column basis. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Nov 28 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From davidrushby at yahoo.com Mon Nov 28 23:45:03 2005 From: davidrushby at yahoo.com (David Rushby) Date: Mon, 28 Nov 2005 14:45:03 -0800 (PST) Subject: [DB-SIG] Accepted method for handling decimals? In-Reply-To: <438B7DCC.1030204@egenix.com> Message-ID: <20051128224504.21032.qmail@web30007.mail.mud.yahoo.com> --- "M.-A. Lemburg" wrote: > However, in general, I think that we should come up with > an easy to use way to map database types to Python > constructors. One which is flexible enough to set these > mappings on a per-cursor and even per-column basis. kinterbasdb 3.2 does all of that. I don't claim the design is pretty, but it implements the column->cursor->connection->module type conversion settings cascade that you spoke of. It has special cases for things like non-materialized (streaming) blob support. The ridiculously clunky Interbase/Firebird C API makes the implementation hairy, but it works. __________________________________ Start your day with Yahoo! - Make it your home page! http://www.yahoo.com/r/hs From carsten at uniqsys.com Tue Nov 29 03:34:45 2005 From: carsten at uniqsys.com (Carsten Haese) Date: Mon, 28 Nov 2005 21:34:45 -0500 Subject: [DB-SIG] Accepted method for handling decimals? In-Reply-To: <438B7DCC.1030204@egenix.com> References: <1133192429.24405.30.camel@dot.uniqsys.com> <438B7DCC.1030204@egenix.com> Message-ID: <20051129020804.M67780@uniqsys.com> On Mon, 28 Nov 2005 22:59:40 +0100, M.-A. Lemburg wrote > Carsten Haese wrote: > > Hi everybody: > > > > I am planning to implement support for decimals in InformixDB > > (http://informixdb.sourceforge.net) using the python decimal module if > > it's available. My question is, should fetches simply return Decimal > > instances instead of floats, or should there be some kind of > > configuration setting to choose whether to return floats or Decimals? If > > so, on what level should that setting reside, module, connection, or > > cursor? > > It is usually a good idea to have such attributes on connections > and cursors - cursors then inherit the setting from the connection > at the time they are created. > > This allows the user to customize the behavior at a connection > or cursor level, as needed. > > > I am leaning towards providing an optional argument to the Cursor() > > constructor for turning on Decimal handling, and by default the cursor > > would return floats. My reasoning here is that returning Decimals would > > incur a (small) performance penalty that the user should only have to > > pay if they need the precision that using Decimals gives them. As far as > > the name of this optional argument, I'm considering "use_decimal", but > > I'm open to suggestions. > > .cursor() normally doesn't take any arguments. That may be true, but InformixDB already has optional arguments to cursor() for providing a cursor name and to enable scroll cursors and cursors with hold. Even mxODBC seems to allow an optional name argument to cursor() unless the documentation you're linking to below is mistaken. > I think the better way is to introduce settable attributes > to connection and cursor objects, e.g. .decimalformat > having values 'float' or 'decimal'. > > mxODBC uses the attributes .datetimeformat and .stringformat > for such customizations: > > http://www.egenix.com/files/python/mxODBC.html#Cursors > > However, in general, I think that we should come up with > an easy to use way to map database types to Python > constructors. One which is flexible enough to set these > mappings on a per-cursor and even per-column basis. That would be ideal, but I'm not sure that my userbase -- which I estimate cautiously according to the SourceForge statistics as "dozens of users" ;-) -- is ready for such flexibility. For now I'm going with the optional use_decimal argument to the cursor, but contrary to my original plan I'm going to default it to True. Thanks, Carsten Haese. From wilk-ml at flibuste.net Wed Nov 30 11:39:59 2005 From: wilk-ml at flibuste.net (William Dode) Date: Wed, 30 Nov 2005 10:39:59 +0000 (UTC) Subject: [DB-SIG] adodbapi and cvtMoney Message-ID: Hi, In adodbapi there is a cvtMoney function with decimal=2 def cvtMoney((hi, lo), decimal=2): TWO32 = 2L ** 32 if lo < 0: lo += TWO32 return round((float((long(hi) << 32) + lo))/10000.0,decimal) I have a MSAccess table with a money field with more decimals, so i had to hack the cvtMoney function to can get theses decimals. Is it a bug of adodbapi or a bug in the database definition ? -- William Dod? - http://flibuste.net