diff options
author | mabitte <user.squall@gmail.com> | 2013-02-27 08:47:33 +0100 |
---|---|---|
committer | Marcel Hellkamp <marc@gsites.de> | 2014-02-04 18:38:00 +0100 |
commit | 41bf831a242e119cf2eb3d7bf4a8955c065fbdcf (patch) | |
tree | 8f43daf786f50231fcdd9ca85968cc88b3bac65a | |
parent | 0aef49f980fe6d27b574c75cd87e06b0bf29c889 (diff) | |
download | bottle-41bf831a242e119cf2eb3d7bf4a8955c065fbdcf.tar.gz |
Update plugins/sqlite/bottle_sqlite.py
Added an optional keyword argument dict 'dbargs' which are passed through to the connect method of the sqlite3 driver
-rw-r--r-- | plugins/sqlite/bottle_sqlite.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/plugins/sqlite/bottle_sqlite.py b/plugins/sqlite/bottle_sqlite.py index 313ecf7..1e29ad4 100644 --- a/plugins/sqlite/bottle_sqlite.py +++ b/plugins/sqlite/bottle_sqlite.py @@ -27,7 +27,7 @@ Usage Example:: ''' __author__ = "Marcel Hellkamp" -__version__ = '0.1.1' +__version__ = '0.1.2' __license__ = 'MIT' ### CUT HERE (see setup.py) @@ -47,11 +47,12 @@ class SQLitePlugin(object): api = 2 def __init__(self, dbfile=':memory:', autocommit=True, dictrows=True, - keyword='db'): + keyword='db', dbargs={}): self.dbfile = dbfile self.autocommit = autocommit self.dictrows = dictrows self.keyword = keyword + self.dbargs = dbargs def setup(self, app): ''' Make sure that other installed plugins don't affect the same @@ -69,6 +70,7 @@ class SQLitePlugin(object): autocommit = conf.get('autocommit', self.autocommit) dictrows = conf.get('dictrows', self.dictrows) keyword = conf.get('keyword', self.keyword) + dbargs = conf.get('dbargs', self.dbargs) # Test if the original callback accepts a 'db' keyword. # Ignore it if it does not need a database handle. @@ -78,7 +80,7 @@ class SQLitePlugin(object): def wrapper(*args, **kwargs): # Connect to the database - db = sqlite3.connect(dbfile) + db = sqlite3.connect(dbfile, **dbargs) # This enables column access by name: row['column_name'] if dictrows: db.row_factory = sqlite3.Row # Add the connection handle as a keyword argument. |