[SQL-CVS] SQLObject/SQLObject DBConnection.py,1.12,1.13
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
|
From: <ian...@us...> - 2003-04-07 07:43:40
|
Update of /cvsroot/sqlobject/SQLObject/SQLObject
In directory sc8-pr-cvs1:/tmp/cvs-serv17939/SQLObject
Modified Files:
DBConnection.py
Log Message:
PostgresConnection accepts keyword arguments matching MySQLConnection
(and creates a dsn out of that). DSN is still accepted as before.
Index: DBConnection.py
===================================================================
RCS file: /cvsroot/sqlobject/SQLObject/SQLObject/DBConnection.py,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** DBConnection.py 7 Apr 2003 01:13:54 -0000 1.12
--- DBConnection.py 7 Apr 2003 07:43:36 -0000 1.13
***************
*** 404,412 ****
class PostgresConnection(DBAPI):
! def __init__(self, dsn, autoCommit=1, **kw):
assert psycopg, 'psycopg module cannot be found'
if not autoCommit and not kw.has_key('pool'):
# Pooling doesn't work with transactions...
kw['pool'] = 0
self.dsn = dsn
DBAPI.__init__(self, **kw)
--- 404,425 ----
class PostgresConnection(DBAPI):
! def __init__(self, dsn=None, host=None, db=None,
! user=None, passwd=None, autoCommit=1, **kw):
assert psycopg, 'psycopg module cannot be found'
if not autoCommit and not kw.has_key('pool'):
# Pooling doesn't work with transactions...
kw['pool'] = 0
+ if dsn is None:
+ dsn = []
+ if db:
+ dsn.append('dbname=%s' % db)
+ if user:
+ dsn.append('user=%s' % user)
+ if passwd:
+ dsn.append('password=%s' % passwd)
+ if host:
+ # @@: right format?
+ dsn.append('host=%s' % host)
+ dsn = ' '.join(dsn)
self.dsn = dsn
DBAPI.__init__(self, **kw)
|