From python at jwp.name Mon Jun 9 03:00:18 2008 From: python at jwp.name (James William Pye) Date: Sun, 8 Jun 2008 18:00:18 -0700 Subject: [DB-SIG] pg_proboscis 1.0 Released Message-ID: pg_proboscis 1.0 has been released. pg_proboscis is a Python programmer's client for PostgreSQL(driver/interface). See [far] below for code examples. Project Site: http://python.projects.postgresql.org/?utm_source=release&utm_medium=email&utm_campaign=pg_proboscis-1.0 It distinguishes itself from other drivers by the following: - BSD/MIT licensed (from some drivers ;) - Pure-Python (Optional C-extension for some speed-ups =) - Binary type transmission (no need to escape bytea, for instance) - Protocol level prepared statements (parameter types are dictated by the server) - Protocol level cursors (You can even use cursors created on the server via GT) - Alternate database APIs (GreenTrunk, for those that aren't fond of DB-API 2.0) - Composite type support - Structured Arrays (including arrays of composite types for some versions of PG) - COPY interfaces that work with arbitrary iterators (See examples further down) - with_statement support for managing transactions, savepoints, and setting contexts - executemany()/query.load() takes advantage of PQ 3.0's extended protocol - So many unittests. Really. And more to come. - Obsessive dedication to creating *great* software. The GreenTrunk API is defined using the ``postgresql.protocol.greentrunk.api`` module. Getting help() on this module or using the included ``pg_greentrunk`` console script yields reference material for using GreenTrunk connections. However, pg_proboscis is not exclusively GreenTrunk, it includes a DB-API 2.0 compliant module as well. [('pyformat' paramstyle) postgresql.interface.proboscis.dbapi2] pg_proboscis is not a monolithic project. It isolates components to encourage targeted packaging and re-usability without unwanted side-code. These packages are at 1.0 as well: pg_foundation Basics. Exception hierarchy, optparse options, SQL string splitter, and much more. (provides ``postgresql.exceptions``) pg_typical Binary type I/O routines. Arrays, composite types, geo types, primitives. Uses pg_foundation's ``postgresql.types`` for some types. pg_pqueue PQ protocol basics. What pg_proboscis uses to do PQ 3.0. pg_greentrunk The GreenTrunk connection APIs are specified in a module herein. Downloading =========== http://python.projects.postgresql.org/files/?utm_source=release&utm_medium=email&utm_campaign=pg_proboscis-1.0 You would need one of each, so it is suggested to just use easy_install: $ easy_install pg_proboscis Documentation ============= The places you will likely want to visit: http://python.projects.postgresql.org/doc/pg_proboscis-1.0.html?utm_source=release&utm_medium=email&utm_campaign=pg_proboscis-1.0 (How to make a connection, and the pb_python command) http://python.projects.postgresql.org/doc/pg_greentrunk-1.0.html?utm_source=release&utm_medium=email&utm_campaign=pg_proboscis-1.0 (Connection APIs) Exception Hierarchy Reside Here[postgresql.exceptions]: http://python.projects.postgresql.org/doc/pg_foundation-1.0.html?utm_source=release&utm_medium=email&utm_campaign=pg_proboscis-1.0 (optparse options, pgpass parser, all sorts of things postgres) If you just want DB-API 2.0, the module path is ``postgresql.interface.proboscis.dbapi2``. GreenTrunk Examples =================== The use of the '~'-operation is exhibited quite freely here. When invoked, query objects return a cursor object, so in order to provide more convenient access to simple data, the '~' can be used to quickly get the first column of the first row of a single-column result set. ``gtx`` is the connection object. These examples come from a ``pb_python`` run. ``pb_python`` is a console script that establishes a connection, binds it to the ``__builtins__`` module as ``gtx``, and then runs the "python command"(provides a Python command with a database connection; ie, interactive console if no script is given). Protocol Level Prepared Statements by Default --------------------------------------------- :: # Create a prepared statement. >>> q = gtx.query('select * from pg_type where typname = $1') >>> q >>> dir(q) ['__call__', '__class__', '__del__', '__delattr__', '__dict__', '__doc__', '__getattribute__', '__hash__', '__init__', '__invert__', '__iter__', '__lshift__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__', '__weakref__', '_input_io', '_output_attmap', '_output_io', '_rformats', 'close', 'closed', 'connection', 'defaults', 'finish', 'first', 'input', 'load', 'output', 'portal', 'prepare', 'prime', 'reprepare', 'statement_id', 'string', 'title'] # Bind a cursor. (typname = 'text') >>> r = q('text') >>> r >>> r.query >>> dir(r) ['__class__', '__del__', '__delattr__', '__dict__', '__doc__', '__getattribute__', '__getitem__', '__hash__', '__init__', '__iter__', '__module__', '__new__', '__next__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__', '__weakref__', '_contract', '_expand', '_mktuple', '_output_attmap', '_output_io', '_rformats', '_state', '_xp_fetchmore', '_xp_move', 'close', 'closed', 'connection', 'fetchcount', 'move', 'next', 'output', 'portal_id', 'query', 'read', 'scroll', 'seek', 'whence_map'] # Grab a row. >>> row1 = r.next() >>> row1 (u'text', 11, 10, -1, False, 'b', True, ',', 0, 0, 1009, u'textin', u'textout', u'textrecv', u'textsend', u'-', u'-', u'-', 'i', 'x', False, 0, -1, 0, None, None) >>> row1.keys() ['typmodin', 'typnamespace', 'typbyval', 'typsend', 'typdelim', 'typnotnull', 'typndims', 'typinput', 'typtypmod', 'typarray', 'typdefault', 'typdefaultbin', 'typtype', 'typisdefined', 'typlen', 'typelem', 'typrelid', 'typreceive', 'typbasetype', 'typalign', 'typname', 'typstorage', 'typanalyze', 'typmodout', 'typowner', 'typoutput'] >>> row1['typlen'] -1 Primitive Types --------------- :: >>> q=gtx.query('select $1::bytea, $2::int, $3::bigint, $4::text') >>> r=q('\x00\x01', 123, 2**34, u'?oobar').next() >>> r ('\x00\x01', 123, 17179869184L, u'\u0192oobar') Arrays ------ :: >>> ~gtx.query("select ARRAY[1::int, 2, 3, 256]") postgresql.types.array([1, 2, 3, 256]) >>> a=~gtx.query("select ARRAY[1::int, 2, 3, 256]") >>> a[0] 1 >>> a[-1] 256 >>> for x in a: ... print x ... 1 2 3 256 >>> Composite Types --------------- :: >>> gtx.execute('create type test as (i int, t text)') >>> cto = ~gtx.query("select (123, 'foo')::test") >>> cto (123, u'foo') >>> cto['t'] u'foo' >>> cto[-1] u'foo' >>> for x in cto: ... print x ... 123 foo COPY TO STDOUT -------------- :: >>> copy=gtx.query('copy (select i from generate_series(1,10) g(i)) to stdout')() >>> copy >>> copy.next() '1\n' >>> copy.next() '2\n' >>> copy.read(10) ['3\n', '4\n', '5\n', '6\n', '7\n', '8\n', '9\n', '10\n'] COPY FROM STDIN --------------- :: >>> gtx.execute('create temp table t (i int, t text)') >>> copy_t = gtx.query('copy t from stdin') >>> copy_t(['%d\t%s\n'%(x,str(x) + 'text') for x in xrange(1, 100)]) >>> ~gtx.query('select count(*) FROM t') 99 >>> for i, t in gtx.query('select * from t where random() < 0.1'): ... print i, t ... 8 8text 9 9text 16 16text 17 17text 27 27text 48 48text 50 50text 62 62text 73 73text 76 76text Incremental COPY FROM STDIN (Not recommended; interface subject to change) -------------------------------------------------------------------------- :: >>> gtx.execute('create temp table t (i int, t text)') >>> copy_t = gtx.query('copy t from stdin') >>> ict = copy_t() >>> ict >>> dir(ict) ['__call__', '__class__', '__delattr__', '__dict__', '__doc__', '__getattribute__', '__hash__', '__init__', '__iter__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__', '__weakref__', '_contract', '_discover_type', '_expand', '_expect_types', '_lastcopy', '_result_types', 'close', 'closed', 'command', 'complete', 'connection', 'count', 'next', 'query', 'read', 'type', 'write', 'xact'] >>> ict.write('3\tjust text\n') >>> ict.close() >>> ~gtx.query("select * from t where t.t = 'just text'") (3, u'just text') >>> ict = copy_t() >>> ict(['3\ttext and %d\n' %(x,) for x in xrange(10)]) >>> ict.close() >>> ~gtx.query("select count(*) from t where t.t ~ 'text and '") 10 Transactions ------------ :: # Error Recovery >>> with gtx.xact: ... gtx.execute('selekt 1') ... Traceback (most recent call last): File "", line 2, in File "build/bdist.freebsd-7.0-RELEASE-i386/egg/postgresql/interface/ proboscis/tracenull.py", line 1845, in execute self._complete() File "build/bdist.freebsd-7.0-RELEASE-i386/egg/postgresql/interface/ proboscis/tracenull.py", line 2378, in _complete self._pop() File "build/bdist.freebsd-7.0-RELEASE-i386/egg/postgresql/interface/ proboscis/tracenull.py", line 2408, in _pop raise xact_error SyntaxError: syntax error at or near "selekt" CODE: 42601 POSITION: 1 LOCATION: File 'scan.l', line 807, in base_yyerror >>> gtx.xact.failed >>> gtx.state 'I' # State difference >>> with gtx.xact: ... try: ... gtx.execute('selekt 1') ... except: ... print 'state: ', gtx.state ... print 'failed: ', str(gtx.xact.failed) ... state: E failed: True >>> gtx.state 'I' # Transaction manager details >>> import sys >>> gtx.tracer = sys.stderr.write >>> with gtx.xact: ... with gtx.xact: ... gtx.execute('select 1') ... ? 'Q'(18): 'START TRANSACTION\x00' ? 'C'(18): 'START TRANSACTION\x00' ? 'Z'(1): 'T' ? 'Q'(20): 'SAVEPOINT "xact(1)"\x00' ? 'C'(10): 'SAVEPOINT\x00' ? 'Z'(1): 'T' ? 'Q'(9): 'select 1\x00' ? 'T'(29): '\x00\x01?column? \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x17\x00\x04\xff\xff\xff\xff \x00\x00' ? 'D'(7): '\x00\x01\x00\x00\x00\x011' ? 'C'(7): 'SELECT\x00' ? 'Z'(1): 'T' ? 'Q'(18): 'RELEASE "xact(1)"\x00' ? 'C'(8): 'RELEASE\x00' ? 'Z'(1): 'T' ? 'Q'(7): 'COMMIT\x00' ? 'C'(7): 'COMMIT\x00' ? 'Z'(1): 'I' >>> del gtx.tracer From andy47 at halfcooked.com Mon Jun 9 12:02:01 2008 From: andy47 at halfcooked.com (Andy Todd) Date: Mon, 09 Jun 2008 20:02:01 +1000 Subject: [DB-SIG] MySQL In-Reply-To: References: Message-ID: <484CFF99.9060809@halfcooked.com> Tariq Momani wrote: > Hello > > > > How I can access MySQL by python in windows XP > > > > Best regards > > Tariq Momani > Redirecting to the db-sig mailing list, where the collected wisdom of the community can help you out. Regards, Andy -- From the desk of Andrew J Todd esq - http://www.halfcooked.com/ From mem at object-craft.com.au Tue Jun 10 03:18:07 2008 From: mem at object-craft.com.au (Mark Matthews) Date: Tue, 10 Jun 2008 11:18:07 +1000 Subject: [DB-SIG] Python to SQL Server Message-ID: <71E45AAC-6BDD-4276-B15F-8E8993832A49@object-craft.com.au> Hello, I have a client that we have built a Python-PostgreSQL-Linux solution for. It works well, very stable, robust ... However, they are a little keen on Microsoft products and are enquiring about migrating to SQL Server (database only, leaving the app running on Linux with Python) I am assuming the best way forward is mxODBC. Has anyone got any better ideas on how to do this. Note that it must be very stable and robust - this is the operations system in a finance company Help appreciated ------------------------------------------------- Mark Matthews General Manager Object Craft Pty Ltd Phone: +61 3 9654 9099 http://www.object-craft.com.au From mal at egenix.com Tue Jun 10 11:40:39 2008 From: mal at egenix.com (M.-A. Lemburg) Date: Tue, 10 Jun 2008 11:40:39 +0200 Subject: [DB-SIG] Python to SQL Server In-Reply-To: <71E45AAC-6BDD-4276-B15F-8E8993832A49@object-craft.com.au> References: <71E45AAC-6BDD-4276-B15F-8E8993832A49@object-craft.com.au> Message-ID: <484E4C17.6060007@egenix.com> On 2008-06-10 03:18, Mark Matthews wrote: > Hello, > > I have a client that we have built a Python-PostgreSQL-Linux solution > for. It works well, very stable, robust ... > > However, they are a little keen on Microsoft products and are enquiring > about migrating to SQL Server (database only, leaving the app running on > Linux with Python) > > I am assuming the best way forward is mxODBC. Has anyone got any better > ideas on how to do this. Note that it must be very stable and robust - > this is the operations system in a finance company If you want to connect to SQL Server from a Linux box, the best way to do this is to use a commercial ODBC driver such as the one from EasySoft and then talk to it via mxODBC. You could also use the free FreeTDS ODBC driver, but it's not really production quality and we don't recommend using it for mission critical applications. BTW: We'll also announce a new product this week which works much like a bridge and avoids having to find an ODBC driver for client application platform. It's still in beta, but we expect the final release by the end of the month. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jun 10 2008) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2008-07-07: EuroPython 2008, Vilnius, Lithuania 26 days to go :::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! :::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 From mem at object-craft.com.au Tue Jun 10 11:49:59 2008 From: mem at object-craft.com.au (Mark Matthews) Date: Tue, 10 Jun 2008 19:49:59 +1000 Subject: [DB-SIG] Python to SQL Server In-Reply-To: <484E4C17.6060007@egenix.com> References: <71E45AAC-6BDD-4276-B15F-8E8993832A49@object-craft.com.au> <484E4C17.6060007@egenix.com> Message-ID: On 10/06/2008, at 7:40 PM, M.-A. Lemburg wrote: > On 2008-06-10 03:18, Mark Matthews wrote: >> Hello, >> I have a client that we have built a Python-PostgreSQL-Linux >> solution for. It works well, very stable, robust ... >> However, they are a little keen on Microsoft products and are >> enquiring about migrating to SQL Server (database only, leaving the >> app running on Linux with Python) >> I am assuming the best way forward is mxODBC. Has anyone got any >> better ideas on how to do this. Note that it must be very stable >> and robust - this is the operations system in a finance company > > If you want to connect to SQL Server from a Linux box, the best way > to do this is to use a commercial ODBC driver such as the one from > EasySoft and then talk to it via mxODBC. > > You could also use the free FreeTDS ODBC driver, but it's not really > production quality and we don't recommend using it for mission > critical applications. > > BTW: We'll also announce a new product this week which works much > like a bridge and avoids having to find an ODBC driver for client > application platform. It's still in beta, but we expect the final > release by the end of the month. Hello Thank you for the prompt response. I had been looking at EasySoft, but was hoping that there were alternatives. I am *very* keen to test your product. Even thought I am not convinced that the client will migrate a stable production system, they do have other SQL Server databases that we extract data from (FreeTDS - which we know to not be production quality). -- Mark Matthews http://www.object-craft.com.au From jkugler at bigfoot.com Tue Jun 10 18:16:28 2008 From: jkugler at bigfoot.com (Joshua Kugler) Date: Tue, 10 Jun 2008 08:16:28 -0800 Subject: [DB-SIG] Python to SQL Server References: <71E45AAC-6BDD-4276-B15F-8E8993832A49@object-craft.com.au> Message-ID: Mark Matthews wrote: > Hello, > > I have a client that we have built a Python-PostgreSQL-Linux solution > for. It works well, very stable, robust ... > > However, they are a little keen on Microsoft products and are > enquiring about migrating to SQL Server (database only, leaving the > app running on Linux with Python) > > I am assuming the best way forward is mxODBC. Has anyone got any > better ideas on how to do this. Note that it must be very stable and > robust - this is the operations system in a finance company You might also want to check out pymssql. It seems pretty stable and robust. j From mal at egenix.com Wed Jun 11 11:15:18 2008 From: mal at egenix.com (M.-A. Lemburg) Date: Wed, 11 Jun 2008 11:15:18 +0200 Subject: [DB-SIG] Python to SQL Server In-Reply-To: References: <71E45AAC-6BDD-4276-B15F-8E8993832A49@object-craft.com.au> <484E4C17.6060007@egenix.com> Message-ID: <484F97A6.6020900@egenix.com> On 2008-06-10 11:49, Mark Matthews wrote: > > On 10/06/2008, at 7:40 PM, M.-A. Lemburg wrote: > >> On 2008-06-10 03:18, Mark Matthews wrote: >>> Hello, >>> I have a client that we have built a Python-PostgreSQL-Linux solution >>> for. It works well, very stable, robust ... >>> However, they are a little keen on Microsoft products and are >>> enquiring about migrating to SQL Server (database only, leaving the >>> app running on Linux with Python) >>> I am assuming the best way forward is mxODBC. Has anyone got any >>> better ideas on how to do this. Note that it must be very stable and >>> robust - this is the operations system in a finance company >> >> If you want to connect to SQL Server from a Linux box, the best way >> to do this is to use a commercial ODBC driver such as the one from >> EasySoft and then talk to it via mxODBC. >> >> You could also use the free FreeTDS ODBC driver, but it's not really >> production quality and we don't recommend using it for mission >> critical applications. >> >> BTW: We'll also announce a new product this week which works much >> like a bridge and avoids having to find an ODBC driver for client >> application platform. It's still in beta, but we expect the final >> release by the end of the month. > > > Hello > > Thank you for the prompt response. I had been looking at EasySoft, but > was hoping that there were alternatives. OpenLink and DataDirect also have SQL Server drivers, so you could try those as well. > I am *very* keen to test your product. Even thought I am not convinced > that the client will migrate a stable production system, they do have > other SQL Server databases that we extract data from (FreeTDS - which we > know to not be production quality). We'll be announcing a public beta this week and also post a copy to this list. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jun 11 2008) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2008-07-07: EuroPython 2008, Vilnius, Lithuania 25 days to go :::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! :::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 From marcelr_br at yahoo.com.br Wed Jun 11 15:40:14 2008 From: marcelr_br at yahoo.com.br (Marcel Rosa) Date: Wed, 11 Jun 2008 06:40:14 -0700 (PDT) Subject: [DB-SIG] Example python x oracle Message-ID: <976782.17910.qm@web50902.mail.re2.yahoo.com> I am Oracle DBA and would like to use a python to developer some intranet report, do you have same examples?   thanks. Abra sua conta no Yahoo! Mail, o ?nico sem limite de espa?o para armazenamento! http://br.mail.yahoo.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From haraldarminmassa at gmail.com Wed Jun 11 16:35:13 2008 From: haraldarminmassa at gmail.com (Harald Armin Massa) Date: Wed, 11 Jun 2008 16:35:13 +0200 Subject: [DB-SIG] Example python x oracle In-Reply-To: <976782.17910.qm@web50902.mail.re2.yahoo.com> References: <976782.17910.qm@web50902.mail.re2.yahoo.com> Message-ID: <7be3f35d0806110735m62714566v9c6b5294ea2b408d@mail.gmail.com> Google up cx_Oracle or directly surf to http://python.net/crew/atuining/cx_Oracle/html/index.html best wishes Harald 2008/6/11 Marcel Rosa : > I am Oracle DBA and would like to use a python to developer some intranet > report, > > do you have same examples? > > > > thanks. > > ________________________________ > Abra sua conta no Yahoo! Mail, o ?nico sem limite de espa?o para > armazenamento! > _______________________________________________ > DB-SIG maillist - DB-SIG at python.org > http://mail.python.org/mailman/listinfo/db-sig > > -- GHUM Harald Massa persuadere et programmare Harald Armin Massa Spielberger Stra?e 49 70435 Stuttgart 0173/9409607 no fx, no carrier pidgeon - EuroPython 2008 will take place in Vilnius, Lithuania - Stay tuned! From anthony.tuininga at gmail.com Thu Jun 12 06:20:03 2008 From: anthony.tuininga at gmail.com (Anthony Tuininga) Date: Wed, 11 Jun 2008 22:20:03 -0600 Subject: [DB-SIG] cx_Oracle 4.4 Message-ID: <703ae56b0806112120p8044aa6p8551cdb2e5f75781@mail.gmail.com> What is cx_Oracle? cx_Oracle is a Python extension module that allows access to Oracle and conforms to the Python database API 2.0 specifications with a few exceptions. Where do I get it? http://cx-oracle.sourceforge.net What's new? 1) Fix setup.py to handle the Oracle instant client and Oracle XE on both Linux and Windows as pointed out by many. Thanks also to the many people who also provided patches. 2) Set the default array size to 50 instead of 1 as the DB API suggests because the performance difference is so drastic and many people have recommended that the default be changed. 3) Added Py_BEGIN_ALLOW_THREADS and Py_END_ALLOW_THREADS around each blocking call for LOBs as requested by Jason Conroy who also provided an initial patch and performed a number of tests that demonstrate the new code is much more responsive. 4) Add support for acquiring cursor.description after a parse. 5) Defer type assignment when performing executemany() until the last possible moment if the value being bound in is null as suggested by Dragos Dociu. 6) When dropping a connection from the pool, ignore any errors that occur during the rollback; unfortunately, Oracle decides to commit data even when dropping a connection from the pool instead of rolling it back so the attempt still has to be made. 7) Added support for setting CLIENT_DRIVER in V$SESSION_CONNECT_INFO in Oracle 11g and higher. 8) Use cx_Oracle.InterfaceError rather than the builtin RuntimeError when unable to create the Oracle environment object as requested by Luke Mewburn since the error is specific to Oracle and someone attempting to catch any exception cannot simply use cx_Oracle.Error. 9) Translated some error codes to OperationalError as requested by Matthew Harriger; translated if/elseif/else logic to switch statement to make it more readable and to allow for additional translation if desired. 10) Transformed documentation to new format using restructured text. Thanks to Waldemar Osuch for contributing the initial draft of the new documentation. 11) Allow the password to be overwritten by a new value as requested by Alex VanderWoude; this value is retained as a convenience to the user and not used by anything in the module; if changed externally it may be convenient to keep this copy up to date. 12) Cygwin is on Windows so should be treated in the same way as noted by Matthew Cahn. 13) Add support for using setuptools if so desired as requested by Shreya Bhatt. 14) Specify that the version of Oracle 10 that is now primarily used is 10.2, not 10.1. Anthony Tuininga From rjkimble at gmail.com Thu Jun 12 02:56:10 2008 From: rjkimble at gmail.com (Bob Kimble) Date: Wed, 11 Jun 2008 20:56:10 -0400 Subject: [DB-SIG] Example python x oracle In-Reply-To: <976782.17910.qm@web50902.mail.re2.yahoo.com> References: <976782.17910.qm@web50902.mail.re2.yahoo.com> Message-ID: <423d3d550806111756i2de8379dp985371da1be6b783@mail.gmail.com> Here's a sample script (cut between the lines): ------------------------------------------------------------------- #!/usr/bin/env python import cx_Oracle # Establish a connection: connection = cx_Oracle.connect('user/password at database') # Create a cursor object: cursor = connection.cursor() # Run your query: cursor.execute('''select to_char(sysdate, 'yyyy-mm-dd hh24:mi:ss') now from dual''') # Get the column names: cols = tuple([x[0].lower() for x in cursor.description]) # Fetch the results: rs = cursor.fetchall() # Turn them into rows: rows = [dict(zip(cols, r)) for r in rs] # Loop through the rows and print out the results: for row in rows: print 'According to Oracle, the time now is:', row['now'] # That's it! ------------------------------------------------------------------- Replace user/password at database with the string you would use to connect to Oracle with SQL*Plus, and that should do it. Good luck! Regards, .... Bob 2008/6/11 Marcel Rosa : > I am Oracle DBA and would like to use a python to developer some intranet > report, > > do you have same examples? > > > > thanks. > > ------------------------------ > Abra sua conta no Yahoo! Mail, > o ?nico sem limite de espa?o para armazenamento! > > _______________________________________________ > DB-SIG maillist - DB-SIG at python.org > http://mail.python.org/mailman/listinfo/db-sig > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From catherine.devlin at gmail.com Thu Jun 12 11:15:42 2008 From: catherine.devlin at gmail.com (Catherine Devlin) Date: Thu, 12 Jun 2008 05:15:42 -0400 Subject: [DB-SIG] Example python x oracle In-Reply-To: <976782.17910.qm@web50902.mail.re2.yahoo.com> References: <976782.17910.qm@web50902.mail.re2.yahoo.com> Message-ID: <6523e39a0806120215jd831df3y67154e176f177ca3@mail.gmail.com> Hi Marcel! Articles on this page should be helpful: http://www.oracle.com/technology/tech/scripting-languages/index.html Depending on what you want, you may also be able to use sqlpython to generate HTML reports: $ sudo easy_install sqlpython $ sqlpython username/password at SID "select * from all_users\h > report.html" quit $ firefox report.html Have fun! 2008/6/11 Marcel Rosa : > I am Oracle DBA and would like to use a python to developer some intranet > report, > > do you have same examples? -- - Catherine http://catherinedevlin.blogspot.com/ *** PyOhio 2008 * Columbus * July 26, 2008 * pyohio.org *** From mal at egenix.com Fri Jun 13 19:52:07 2008 From: mal at egenix.com (M.-A. Lemburg) Date: Fri, 13 Jun 2008 19:52:07 +0200 Subject: [DB-SIG] Python to SQL Server In-Reply-To: <484F97A6.6020900@egenix.com> References: <71E45AAC-6BDD-4276-B15F-8E8993832A49@object-craft.com.au> <484E4C17.6060007@egenix.com> <484F97A6.6020900@egenix.com> Message-ID: <4852B3C7.1060309@egenix.com> On 2008-06-11 11:15, M.-A. Lemburg wrote: > On 2008-06-10 11:49, Mark Matthews wrote: >>> BTW: We'll also announce a new product this week which works much >>> like a bridge and avoids having to find an ODBC driver for client >>> application platform. It's still in beta, but we expect the final >>> release by the end of the month. >> >> >> Hello >> >> Thank you for the prompt response. I had been looking at EasySoft, but >> was hoping that there were alternatives. > > OpenLink and DataDirect also have SQL Server drivers, so you could > try those as well. > >> I am *very* keen to test your product. Even thought I am not convinced >> that the client will migrate a stable production system, they do have >> other SQL Server databases that we extract data from (FreeTDS - which >> we know to not be production quality). > > We'll be announcing a public beta this week and also post a copy > to this list. Hello Mark, FYI: we've put beta online today ... http://www.egenix.com/company/news/eGenix-mxODBC-Connect-0.9.1-beta.html the announcement emails will go out on Monday. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jun 13 2008) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2008-07-07: EuroPython 2008, Vilnius, Lithuania 23 days to go :::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! :::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 From info at egenix.com Mon Jun 16 12:13:22 2008 From: info at egenix.com (eGenix Team: M.-A. Lemburg) Date: Mon, 16 Jun 2008 12:13:22 +0200 Subject: [DB-SIG] ANN: eGenix mxODBC Connect Database Interface for Python 0.9.1 (beta) Message-ID: <48563CC2.5020709@egenix.com> ________________________________________________________________________ ANNOUNCING eGenix.com mxODBC Connect Database Interface for Python Version 0.9.1 (beta) Our new client-server product for connecting Python applications to relational databases - on all major platforms This announcement is also available on our web-site for online reading: http://www.egenix.com/company/news/eGenix-mxODBC-Connect-0.9.1-beta.html ________________________________________________________________________ INTRODUCTION The mxODBC Connect Database Interface for Python allows users to easily connect Python applications to all major databases on the market today in a highly portable and convenient way. This makes mxODBC Connect the ideal basis for writing cross-platform database programs and utilities in Python. mxODBC Connect extends our eGenix mx Python Extension series with a new client-server based product, that removes the need to install and configure ODBC drivers on the client side. This greatly simplifies setup and configuration of database driven client applications, while at the same time making the network communication between client and database server more efficient and more secure. * About Python: Python is an object-oriented Open Source programming language which runs on all modern platforms (http://www.python.org/). By integrating ease-of-use, clarity in coding, enterprise application connectivity and rapid application design, Python establishes an ideal programming platform for todays IT challenges. * About eGenix: eGenix is a consulting and software product company focused on providing professional quality services and products to Python users and developers (http://www.egenix.com/). ________________________________________________________________________ HOW IT WORKS mxODBC Connect consists of two parts: a server installation which typically runs directly on the database server and a client Python package which is installed on the client machine that runs the Python application. The server part uses our high-performance database adapter mxODBC to connect to the database server. The client package communicates with the server part over a TCP/IP network, optionally using SSL encryption, advanced authentication and access controls - a feature that many database drivers fail to deliver. By separating the client application database interface from the server and using mxODBC Connect, you gain several benefits: * high portability and flexibility * centralized configuration and administration * added security * automatic fail-over * scalability * lower costs For more information, please have a look at the product page: http://www.egenix.com/products/python/mxODBCConnect/ ________________________________________________________________________ NEWS mxODBC Connect 0.9 is a public beta release of our new mxODBC Connect product. If you would like to participate in the beta, please see our beta program page: http://www.egenix.com/products/python/mxODBCConnect/beta.html *SPECIAL OFFER* In order to make participation in the beta program more interesting for our users, we will be giving out *free discount coupons* to all participants who report back bugs in the product. ________________________________________________________________________ DOWNLOADS The download archives as well as instructions for installation and configuration of the product can be found on the product page: http://www.egenix.com/products/python/mxODBCConnect/ _______________________________________________________________________ SUPPORT Commercial support for this product is available from eGenix.com. Please see http://www.egenix.com/services/support/ for details about our support offerings. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jun 16 2008) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2008-07-07: EuroPython 2008, Vilnius, Lithuania 20 days to go :::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! :::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 From info at egenix.com Wed Jun 18 18:27:41 2008 From: info at egenix.com (eGenix Team: M.-A. Lemburg) Date: Wed, 18 Jun 2008 18:27:41 +0200 Subject: [DB-SIG] ANN: eGenix mx Base Distribution 3.1.0 Message-ID: <4859377D.30508@egenix.com> ________________________________________________________________________ ANNOUNCING eGenix.com mx Base Distribution Version 3.1.0 Open Source Python extensions providing important and useful services for Python programmers. This announcement is also available on our web-site for online reading: http://www.egenix.com/company/news/eGenix-mx-Base-Distribution-3.1.0-GA.html ________________________________________________________________________ ABOUT The eGenix.com mx Base Distribution for Python is a collection of professional quality software tools which enhance Python's usability in many important areas such as fast text searching, date/time processing and high speed data types. The tools have a proven record of being portable across many Unix and Windows platforms. You can write applications which use the tools on Windows and then run them on Unix platforms without change due to the consistent platform independent interfaces. Contents of the distribution: * mxDateTime - Date/Time Library for Python * mxTextTools - Fast Text Parsing and Processing Tools for Python * mxProxy - Object Access Control for Python * mxBeeBase - On-disk B+Tree Based Database Kit for Python * mxURL - Flexible URL Data-Type for Python * mxUID - Fast Universal Identifiers for Python * mxStack - Fast and Memory-Efficient Stack Type for Python * mxQueue - Fast and Memory-Efficient Queue Type for Python * mxTools - Fast Everyday Helpers for Python All available packages have proven their stability and usefulness in many mission critical applications and various commercial settings all around the world. * About Python: Python is an object-oriented Open Source programming language which runs on all modern platforms (http://www.python.org/). By integrating ease-of-use, clarity in coding, enterprise application connectivity and rapid application design, Python establishes an ideal programming platform for todays IT challenges. * About eGenix: eGenix is a consulting and software product company focused on providing professional quality services and products to Python users and developers (http://www.egenix.com/). ________________________________________________________________________ NEWS The 3.1.0 release of the eGenix mx Base Distribution has a number of enhancements over the previous version 3.0.0. Apart from a few minor bug fixes, it provides a few new features: Some highlights: * mxTools now has a new mx.Tools.dlopen() function which allow loading shared libraries explicitly and from a specific path. This allows working around problems with not being able to dynamically set LD_LIBRARY_PATH on Unix platforms. * mxTools can be configured to expose a new API called mx.Tools.setproctitle() which allows setting the process title on Unix platforms. * mxBeeBase comes with a new on-disk dictionary version called BeeFixedLengthStringDict, which allows using keys with embedded \0 characters. * mxSetup, our Python distutils extension, can now build prebuilt archives that no longer require the "... build --skip ..." command to skip the build process. The uninstall command now also works for prebuilt archives and the bdist_prebuilt command has been enhanced to be able to build pure Python distributions as well. * mxSetup now also works together with setuptools to e.g. build and install the packages as eggs. Run setup.py with --use-setuptools to enable this support. For a more detailed description of changes, please see the respective package documentation on our web-site. As always, we are providing pre-compiled versions of the package for the most popular Python platforms. For all others, you can compile the package from source using "python setup.py install". ________________________________________________________________________ DOWNLOADS The download archives and instructions for installing the packages can be found on the eGenix mx Base Distribution page: http://www.egenix.com/products/python/mxBase/ ________________________________________________________________________ LICENSE The eGenix mx Base package is distributed under the eGenix.com Public License 1.1.0 which is a CNRI Python License style Open Source license. You can use the package in both commercial and non-commercial settings without fee or charge. The package comes with full source code ________________________________________________________________________ SUPPORT Commercial support for these packages is available from eGenix.com. Please see http://www.egenix.com/services/support/ for details about our support offerings. Enjoy, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jun 18 2008) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2008-07-07: EuroPython 2008, Vilnius, Lithuania 18 days to go :::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! :::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611