Skip to content

Commit

Permalink
DBconnection updated, to help with multiple connections
Browse files Browse the repository at this point in the history
  • Loading branch information
bart mosley committed Aug 2, 2011
1 parent 22b8e2f commit a0e6028
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions db/dbconnection.py
Expand Up @@ -4,6 +4,8 @@
This class keeps track of what kind of connection you have (sqlite,mysql, pyodbc)
and has a 'close()' method that is easily accessible.
Using this class helps deal with multiple database connections.
*dbtype*
Values 'sqlite3', 'mysql', 'pyodbc'. 'mysql' uses the MySQLdb package to connect.
'pyodbc' supports the use of connection strings and
Expand Down Expand Up @@ -42,14 +44,15 @@ def getconnection(self, dbtype=None, db=None, dbfile=None, **kwcfg):
dbfile = os.path.join(dbfile,db)
else:
pass # because dbfile better be a good file name
self.dbname = db
if 'user' in kwcfg:
self.user = kwcfg['user']
else:
self.user = None

if db:
kwcfg.update({'DATABASE': db})
self.dbname = db
if 'user' in kwcfg:
self.user = kwcfg['user']
else:
self.user = None

if db:
kwcfg.update({'DATABASE': db})

self.connect(dbtype, dbfile, **kwcfg)

Expand Down

0 comments on commit a0e6028

Please sign in to comment.