From anthony.tuininga at gmail.com Wed Jan 11 05:23:56 2006 From: anthony.tuininga at gmail.com (Anthony Tuininga) Date: Tue, 10 Jan 2006 21:23:56 -0700 Subject: [DB-SIG] cx_Logging 1.1 Message-ID: <703ae56b0601102023j4940162dxb7c4b511301110d7@mail.gmail.com> What is cx_Logging? cx_Logging is a Python extension module which operates in a fashion similar to the logging module that ships with Python 2.3 and higher. It also has a C interface which allows applications to perform logging independently of Python. Where do I get it? http://starship.python.net/crew/atuining What's new? 1) Raise an exception if a write fails during logging. 2) Add module constants version and buildtime in order to aid in support and debugging. Anthony Tuininga From travislspencer at gmail.com Sat Jan 14 09:46:23 2006 From: travislspencer at gmail.com (Travis Spencer) Date: Sat, 14 Jan 2006 00:46:23 -0800 Subject: [DB-SIG] UML diagram of Python DB API 2.0 specification Message-ID: Hello All, My research group is using two Python DB API-compliant modules to interface with a couple backend database servers. Last term, I was asked to do some work on this aspect of our project for the first time. I didn't know anything about database programming in Python, so one of my colleagues pointed me to the Python DB API specification[1]. She said that studying it would show me how to work with each of the two modules since both conformed to the same interface. It was very useful indeed! However, as I read it and reread it and re-reread it, I found myself reaching for some succinct overview that summarized the entire API -- something that I could easily and frequently refer back to when I needed to look up from the details and take in the entire specification. Not finding such a resource, I created a UML diagram that illustrates the specification's API in a broad sense. It shows the mandated classes, each one's fields and operations, and how they all fit together into one package. Specifically, the diagram shows the four top-level classes and the module-level functions. It depicts how the the top-level Error class is the root of an inheritance hierarchy containing the seven specified descendants. The relationship that these classes have to the Connection class's optional Error field is illustrated with a UML associate (an arrow). Uninterestingly but necessary, the Warning class is also shown. And then comes the good stuff: the Connection and Cursor classes. With one glance, you can learn all sorts of information about the Connection class. For instance, you can immediately see that it could have as few as three attributes: the close, commit, and cursor methods; the other attributes are optional. All the information that you can glean from the diagram is present in the specification of course, but this alternative presentation format makes some things easier to see. For instance, the errorhandlers field is way at the end of the specification where it can be easily overlooked; however, this diagram pulls it to the forefront. Likewise, the Cursor class's optional and required attributes can be seen very obviously. This clarity reveals many methods and fields such as __iter__, lastrowid, and messages that otherwise require a couple of readings before they are first noticed. Lastly, the diagram shows the package-level attributes that are defined by the standard. The scope of these is illustrated by their position in a UML utility stereotype called global. I would like to share this resource with everyone in hopes that it will help others get the big picture of what exactly the Python DB API is setting forth. For this reason, I'm freely releasing my UML diagram's original source document (a Microsoft Visio file) and various other formats that I've produced from it. I am licencing all of these under the GNU Free Documentation License (GFDL), so you can use them in any way that complies with that license. I'm willing to relicense it under the same one that the Python documentation is governed by if need be. You will find the UML diagram in the following formats at each respective URL: Microsoft Visio Drawing Format (VSD) http://www.travisspencer.com/stash2/projects/perftrack/umldiagram/dbapi2.vsd PDF http://www.travisspencer.com/stash2/projects/perftrack/umldiagram/dbapi2.pdf TIFF http://www.travisspencer.com/stash2/projects/perftrack/umldiagram/dbapi2.tif LZW Compressed TIFF http://www.travisspencer.com/stash2/projects/perftrack/umldiagram/dbapi2.Z.tif EPS http://www.travisspencer.com/stash2/projects/perftrack/umldiagram/dbapi2.eps GIF http://www.travisspencer.com/stash2/projects/perftrack/umldiagram/dbapi2.gif PNG http://www.travisspencer.com/stash2/projects/perftrack/umldiagram/dbapi2.png JPEG http://www.travisspencer.com/stash2/projects/perftrack/umldiagram/dbapi2.jpg Microsoft Visio XML Drawing (VDX) http://www.travisspencer.com/stash2/projects/perftrack/umldiagram/dbapi2.vdx I hope this diagram helps others get oriented as they learn more about the Python Database API, build new compliant drivers, or use existing ones. If you have any comments or questions, please feel free to share them (here on the list or privately via email). I am happy to help if I can and always appreciative of any constructive criticisms. -- Regards, Travis Spencer [1] http://www.python.org/peps/pep-0249.html From pobrien at orbtech.com Sat Jan 14 16:11:46 2006 From: pobrien at orbtech.com (Patrick K. O'Brien) Date: Sat, 14 Jan 2006 09:11:46 -0600 Subject: [DB-SIG] UML diagram of Python DB API 2.0 specification In-Reply-To: References: Message-ID: <43C914B2.6020209@orbtech.com> Travis Spencer wrote: > [details snipped] > > I would like to share this resource with everyone in hopes that it > will help others get the big picture of what exactly the Python DB API > is setting forth. For this reason, I'm freely releasing my UML > diagram's original source document (a Microsoft Visio file) and > various other formats that I've produced from it. I am licencing all > of these under the GNU Free Documentation License (GFDL), so you can > use them in any way that complies with that license. I'm willing to > relicense it under the same one that the Python documentation is > governed by if need be. Very nice. I'm sure others will find this most helpful. -- Patrick K. O'Brien Orbtech http://www.orbtech.com Schevo http://www.schevo.org Louie http://louie.berlios.de From gh at ghaering.de Sun Jan 15 18:17:15 2006 From: gh at ghaering.de (=?ISO-8859-1?Q?Gerhard_H=E4ring?=) Date: Sun, 15 Jan 2006 18:17:15 +0100 Subject: [DB-SIG] [ANN] pysqlite 2.1.0 released Message-ID: <43CA839B.5020305@ghaering.de> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 pysqlite 2.1.0 released ======================= I'm pleased to announce the availability of pysqlite 2.1.0. This is a major release with many new features and some internal changes. While the code was tested by a few people who tracked Subversion, users are still adviced to test their applications intensively with the new release before upgrading them to pysqlite 2.1.0. Go to http://pysqlite.org/ for downloads, online documentation and reporting bugs. What is pysqlite? pysqlite is a DB-API 2.0-compliant database interface for SQLite. SQLite is a relational database management system contained in a relatively small C library. It is a public domain project created by D. Richard Hipp. Unlike the usual client-server paradigm, the SQLite engine is not a standalone process with which the program communicates, but is linked in and thus becomes an integral part of the program. The library implements most of SQL-92 standard, including transactions, triggers and most of complex queries. pysqlite makes this powerful embedded SQL engine available to Python programmers. It stays compatible with the Python database API specification 2.0 as much as possible, but also exposes most of SQLite's native API, so that it is for example possible to create user-defined SQL functions and aggregates in Python. If you need a relational database for your applications, or even small tools or helper scripts, pysqlite is often a good fit. It's easy to use, easy to deploy, and does not depend on any other Python libraries or platform libraries, except SQLite. SQLite itself is ported to most platforms you'd ever care about. It's often a good alternative to MySQL, the Microsoft JET engine or the MSDE, without having any of their license and deployment issues. ======= CHANGES ======= Statement caching ================= Planned since the start of the pysqlite2 development, the most difficult to implement feature has now been implemented: transparent statement caching. What is statement caching? Every SQL engine has a COMPILE and EXECUTE phase. In older pysqlite releases, every SQL statement (except for executemany) was always COMPILED and EXECUTED. With statement caching, pysqlite can transparently optimize away the COMPILE step. The statement cache is implemented using a LRU cache with a default capacity of 100. The cache is per connection - it's capacity can be set when opening a connection: con = sqlite.connect(..., cached_statements=30) In a nutshell, this means the 100 most used SQL statements in your application will only have to be COMPILED once by the SQLite engine. This will of course only work well if you use the parameter-form of the execute() method, i. e. for: cur.execute("insert into foo(bar) values (?)", ("xy",)) cur.execute("insert into foo(bar) values (?)", ("ab",)) the SQL statement "insert into foo(bar) values (?)" will then only be compiled once. Users have seen significant performance improvements with the statement caching in pysqlite 2.1.0: http://lists.initd.org/pipermail/pysqlite/2005-November/000234.html More flexibility for TEXT data ============================== Until now, pysqlite would always return Unicode strings for text data, unless you did some crazy trickery. If you prefer to retrieve text data as Python bytestrings or a different type, you can now set a text_factory callable per connection: con.text_factory = str # ... to always return bytestrings An optimized shortcut has been enabled to retrieve Unicode strings for non-ASCII data, but bytestrings for non-ASCII text: con.text_factory = sqlite.OptimizedUnicode or something custom: con.text_factory = lambda x: unicode(x, "utf-8", "ignore") Highly optimized row_factory for column access by name ====================================================== A new function has been implemented that allows for case-insensitive column access by name with minimal performance and memory impact, unlike a dictionary or db_row-based approach. To enable it, set the row_factory attribute of your connection to sqlite.Row: from pysqlite2 import dbapi2 as sqlite con = sqlite.connect(...) con.row_factory = sqlite.Row cur = con.cursor() cur.execute("select name_last, age from people") for row in cur: print row["Name_Last"], row[1] Convenience methods =================== The execute(), executemany() and executescript() methods are now also available in the Connection class. This allows you to write very concise code like this: con = sqlite.connect(...) con.execute("insert into foo(bar) values (5)") for row in con.execute("select bar from foo"): print row API changes =========== The row_factory attribute has been moved from the Cursor class to the Connection class. For backwards compatibility, using it on the Cursor class still works. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFDyoObdIO4ozGCH14RAt9uAJ9EO8jHuLjhPleYjWWUe+lt++GsngCeInQY CxfGAxmV5I8UMuM620wWTac= =jsNu -----END PGP SIGNATURE----- From rshzky at yahoo.com Tue Jan 24 12:53:52 2006 From: rshzky at yahoo.com (Rasha Ebo) Date: Tue, 24 Jan 2006 03:53:52 -0800 (PST) Subject: [DB-SIG] MS Sql Server DBI Message-ID: <20060124115352.28834.qmail@web30413.mail.mud.yahoo.com> Hi, I am a newbebie to python, I want to connect to microsoft sql server 2000 database. I have searched al ot and understood that need to download a dbi that works as an a connection between python and the database. Can anybody refer me to free reliable DBI that connects to microsoft sql server 2000. Thanks a lot for every one. --------------------------------- Yahoo! Autos. Looking for a sweet ride? Get pricing, reviews, & more on new and used cars. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/db-sig/attachments/20060124/ff1db2a2/attachment.html From mal at egenix.com Tue Jan 24 22:24:13 2006 From: mal at egenix.com (M.-A. Lemburg) Date: Tue, 24 Jan 2006 22:24:13 +0100 Subject: [DB-SIG] MS Sql Server DBI In-Reply-To: <20060124115352.28834.qmail@web30413.mail.mud.yahoo.com> References: <20060124115352.28834.qmail@web30413.mail.mud.yahoo.com> Message-ID: <43D69AFD.1040701@egenix.com> Rasha Ebo wrote: > Hi, > I am a newbebie to python, I want to connect to microsoft sql server 2000 database. I have searched al ot and understood that need to download a dbi that works as an a connection between python and the database. Can anybody refer me to free reliable DBI that connects to microsoft sql server 2000. Our mxODBC will do the job nicely: http://www.egenix.com/files/python/mxODBC.html It's free for personal use. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 24 2006) >>> 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 David.Carey at nyscot.ang.af.mil Wed Jan 25 13:11:22 2006 From: David.Carey at nyscot.ang.af.mil (Carey David CIV 109CF/SCBJ) Date: Wed, 25 Jan 2006 07:11:22 -0500 Subject: [DB-SIG] MS Sql Server DBI Message-ID: <200601251207.k0PC78IB003657@gandalf.nyscot.ang.af.mil> Python comes with an ODBC module that provides limited functionality. However, the mxODBC module mentioned below is very good. Dave //SIGNED// David Carey GS-09 IT Specialist 109 CF/SCB Stratton ANGB Scotia, NY Comm: (518) 344-2572 DSN: 344-2572 -----Original Message----- From: M.-A. Lemburg [mailto:mal at egenix.com] Sent: Tuesday, January 24, 2006 4:24 PM To: Rasha Ebo Cc: db-sig at python.org Subject: Re: [DB-SIG] MS Sql Server DBI Rasha Ebo wrote: > Hi, > I am a newbebie to python, I want to connect to microsoft sql server 2000 database. I have searched al ot and understood that need to download a dbi that works as an a connection between python and the database. Can anybody refer me to free reliable DBI that connects to microsoft sql server 2000. Our mxODBC will do the job nicely: http://www.egenix.com/files/python/mxODBC.html It's free for personal use. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 24 2006) >>> 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 ! :::: _______________________________________________ DB-SIG maillist - DB-SIG at python.org http://mail.python.org/mailman/listinfo/db-sig From henrik at evahjelte.com Wed Jan 25 09:02:48 2006 From: henrik at evahjelte.com (henrik hjelte) Date: Wed, 25 Jan 2006 09:02:48 +0100 Subject: [DB-SIG] MS Sql Server DBI In-Reply-To: <20060124115352.28834.qmail@web30413.mail.mud.yahoo.com> References: <20060124115352.28834.qmail@web30413.mail.mud.yahoo.com> Message-ID: <1138176168.6575.3.camel@localhost.localdomain> On tis, 2006-01-24 at 03:53 -0800, Rasha Ebo wrote: > Hi, > I am a newbebie to python, I want to connect to microsoft sql > server 2000 database. I have searched al ot and understood that need > to download a dbi that works as an a connection between python and the > database. Can anybody refer me to free reliable DBI that connects to > microsoft sql server 2000. > Thanks a lot for every one. > > ______________________________________________________________________ Adodbapi is a free windows-only solution. http://adodbapi.sourceforge.net /Henrik Hjelte From anthony.tuininga at gmail.com Thu Jan 26 18:16:49 2006 From: anthony.tuininga at gmail.com (Anthony Tuininga) Date: Thu, 26 Jan 2006 10:16:49 -0700 Subject: [DB-SIG] cx_OracleDBATools 2.1 Message-ID: <703ae56b0601260916w2cc96bf0qba809e7550c6b457@mail.gmail.com> What is cx_OracleDBATools? cx_OracleDBATools is a set of Python scripts that handle Oracle DBA tasks in a cross platform manner. These scripts are intended to work the same way on all platforms and hide the complexities involved in managing Oracle databases, especially on Windows. Binaries are provided for those who do not have a Python installation. Where do I get it? http://starship.python.net/crew/atuining What's new? 1) Added support for Oracle 10g. 2) Enhanced CreateDB to treat all unknown keys in each database type section of the configuration file and additional parameters after the SID on the command line as user specified parameters that will be used when doing the substitution in the template init.ora, template creation sql, and the template directory files. 3) Enhanced ExportControlFile to include the current archive log mode so when the control file is recreated, it will be the same. 4) Enhanced BackupDB to allow lower level compression by adding the --compress option. 5) Enhanced RestoreDB to display information about a backup file without having to restore the database by adding the options --info (prints summary information) and --list (lists all files in the backup). 6) Enhanced RestoreDB to allow the changing of ORACLE_HOME when restoring a database as a different SID. 7) Enhanced StartDB to allow restarting the database if it is already started by adding the options --restart and --shutdown-mode. 8) Enhanced RestoreDB to remove an existing database if desired by adding the options --replace-existing, --tnsentry and --sys-password. 9) Added simple script which examines the memory maps on Linux to determine how much shared/private/mapped memory is in use. The output of this script is still less than useful for the shared and mapped memory. 10) Stopped backing up temporary files since they can be rebuilt faster upon restore. 11) Fixed the problem of backing up the same directory twice under file systems that are not case sensitive. 12) Fixed parsing of the log_archive_dest parameter. 13) Removed restriction on the new directory being different from the old one when performing a restore so that restoring to the same location on a different machine is possible. 14) Put password in quotes in the templates so that it does not have to follow Oracle naming conventions. 15) Added parameter db_cache_size as another size parameter. 16) Split the template OracleControl.ini into files for Windows and files for Unix type machines. Anthony Tuininga From anthony.tuininga at gmail.com Thu Jan 26 22:31:59 2006 From: anthony.tuininga at gmail.com (Anthony Tuininga) Date: Thu, 26 Jan 2006 14:31:59 -0700 Subject: [DB-SIG] cx_OracleTools 7.3 Message-ID: <703ae56b0601261331x3bca07kb002feb29375ea06@mail.gmail.com> What is cx_OracleDBATools? cx_OracleTools is a set of Python scripts that handle Oracle database development tasks in a cross platform manner and improve (in my opinion) on the tools that are available by default in an Oracle client installation. Those who use cx_Oracle (a Python interface driver for Oracle compatible with the DB API) may also be interested in this project, if only as examples. Binaries are provided for those who do not have a Python installation. Where do I get it? http://starship.python.net/crew/atuining What's new? 1) Added ExportXML and ImportXML utilities for importing and exporting data from an Oracle database as XML. 2) Added support in ExportData for limiting the number of rows exported and skipping some rows first. 3) Added support in CopyData for the case where all the columns on the target table form the primary key. 4) Added support for case sensitive tables and column names in CopyData. 5) Added option --report-point to CopyData which defaults to --commit-point. 6) Added options --log-file, --log-level and --log-prefix to all of the tools and removed --timestamp and --prefix on DbDebugger since the new options cover the functionality of the old ones. 7) Added options --suppress-owner-dir, --include-roles, --include-users, --no-related and --no-triggers to ExportObjects. 8) Added option --sort-by to DumpData to modify the query executed to include a sort clause. 9) Added option --only-if to DescribeSchema and ExportObjects which allows for filtering the objects described by a where clause against dba_objects. 10) DbDebugger now displays the time to the microsecond if desired. 11) GeneratePatch now makes sure that owner changes are displayed before displaying anything about the objects for that owner that are being patched. 12) GeneratePatch now produces consistent results by performing a sort before displaying any results. 13) Fixed bug in GeneratePatch parsing grants with the "with grant option" specified. 14) Fixed bug in DescribeObject where connect statements were being displayed. Anthony Tuininga From richmoore44 at gmail.com Sun Jan 29 00:57:04 2006 From: richmoore44 at gmail.com (Richard Moore) Date: Sat, 28 Jan 2006 23:57:04 +0000 Subject: [DB-SIG] Feature enhancement for DB API Message-ID: <5491a5150601281557i3cb6cd80nf8149f14140bd8e2@mail.gmail.com> Hi all, At work, we've recently been preparing to release a python tool that is built on top of the DB API, but which does not have ties to any particular database. I had expected to be able to use something analogous to the way JDBC allows you to create database connections from a special form of URL to allow us to avoid putting any code into the library that depends on particular databases. Unfortunately the DB API doesn't seem to offer this facility at all. Looking around I see the sqlobject library has implemented this kind of facility, but it is unfortunately tightly coupled to the rest of that library. It does however show that our tool is not alone in this requirement. I've written a simple factory class that provides the ability to create a database connection from a URL-like string, and written a driver for sqlite, I'll also be writing one for cx_Oracle, but I don't have access to that at home. The code is trivial, but seems to be a decent starting place. The idea is that the main pydb file could be added to the python standard library, with individual database drivers being able to add their own modules to the dbdrivers directory to register themselves with the factory. The code is available at: http://xmelegance.org/downloads/pydbfactory.zip I hope that I might be able to get some feedback. Cheers Rich. From python_eager at yahoo.com Tue Jan 31 08:53:58 2006 From: python_eager at yahoo.com (python eager) Date: Mon, 30 Jan 2006 23:53:58 -0800 (PST) Subject: [DB-SIG] how to compare Message-ID: <20060131075358.90108.qmail@web36401.mail.mud.yahoo.com> Hi , > here i am comparing both the values of form value and table value. > But it will not work . The result will be print "not equal". Table values > are retrieved fine. Here what mistake i did. No compilation error and run > time error. Please solve this problem. > > Code Snippet : > > req = self.request() > pid = int(req.field('pid')) > self.writeln(pid) > > dbconnection = cx_Oracle.connect("myusername", "mypassword", > "mydatabase") > cursor = dbconnection.cursor() > cursor.arraysize = 50 > cursor.execute("SELECT PID FROM PERSONALDETAILS order by pid") > for PID in cursor.fetchall(): > # Comparing here both formvalue and table value ( both are > numeric) > if pid==PID: > self.writeln("Equal") > else: > self.writeln("Not Equal") > > Thank you > Python_Eager --------------------------------- Bring words and photos together (easily) with PhotoMail - it's free and works with Yahoo! Mail. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/db-sig/attachments/20060130/cddd506b/attachment.htm From carsten at uniqsys.com Tue Jan 31 14:28:05 2006 From: carsten at uniqsys.com (Carsten Haese) Date: Tue, 31 Jan 2006 08:28:05 -0500 Subject: [DB-SIG] how to compare In-Reply-To: <20060131075358.90108.qmail@web36401.mail.mud.yahoo.com> References: <20060131075358.90108.qmail@web36401.mail.mud.yahoo.com> Message-ID: <1138714085.32717.12.camel@dot.uniqsys.com> On Tue, 2006-01-31 at 02:53, python eager wrote: > Hi , > > here i am comparing both the values of form value and table > value. > > But it will not work . The result will be print "not equal". Table > values > > are retrieved fine. Here what mistake i did. No compilation error > and > run > > time error. Please solve this problem. > > > > Code Snippet : > > > > req = self.request() > > pid = int(req.field('pid')) > > self.writeln(pid) > > > > dbconnection = cx_Oracle.connect("myusername", > "mypassword", > > "mydatabase") > > cursor = dbconnection.cursor() > > cursor.arraysize = 50 > > cursor.execute("SELECT PID FROM PERSONALDETAILS order by > pid") > > for PID in cursor.fetchall(): > > # Comparing here both formvalue and table value ( both > are > > numeric) > > if pid==PID: > > self.writeln("Equal") > > else: > > self.writeln("Not Equal") First of all, this approach for checking whether a row in a table has a certain value is very inefficient, to put it mildly. You should really use a WHERE clause in your query to perform the comparison on the server side instead of on the client side. (If there is an index on the PID column, and it sounds like there should be, the server will actually use an index lookup instead of fetching and inspecting all rows!) That said, your comparisons are failing because the fetch methods return tuples, even if you're only selecting a single columns. You're comparing the integer pid with the singleton tuple PID, which will always be false. You'd have to compare pid to PID[0] to make the comparison come out as expected. Hope this helps, Carsten.