Skip to content

Commit

Permalink
Merge pull request #2 from BYK/master
Browse files Browse the repository at this point in the history
Keyword arguments support for SQLite
  • Loading branch information
Bart Mosley committed May 13, 2011
2 parents 7c96700 + 3a22ff3 commit e0a7508
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions db/connection.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@

class Database(object):
placeholder = '?'

def connect(self, dbtype, *args, **kwargs):
if dbtype == 'sqlite3':
import sqlite3
self.connection = sqlite3.connect(*args)
self.connection = sqlite3.connect(*args, **kwargs)
self.lastrowid_ = "LAST_INSERT_ROWID()"
elif dbtype == 'mysql':
import MySQLdb
Expand All @@ -18,16 +18,16 @@ def connect(self, dbtype, *args, **kwargs):
self.connection.autocommit = True
self.lastrowid_ = "LAST_INSERT_ID()"
self.placeholder = '?'

def lastrowid(self):
idCursor = self.connection.cursor()
qry = "SELECT %s AS last_row_id" % self.lastrowid_
idCursor.execute(qry)

rc = idCursor.fetchone()

return rc[0] if rc else None

class DBConn(object):
def __init__(self, connector=None):
self.b_debug = False
Expand Down

0 comments on commit e0a7508

Please sign in to comment.