@@ 41,7 41,7 @@ Let's set up a test database::
>>> import os
>>> from deeno.db import SQLiteDatabase
- >>> db = SQLiteDatabase(config={'path': ':memory:'})
+ >>> db = SQLiteDatabase(':memory:')
>>> db.execute("""
... CREATE TABLE customer (
... customer_id INTEGER PRIMARY KEY,
@@ 222,8 222,7 @@ class Database(object):
schema_separator_char = None
script_func = 'execute'
- def __init__(self, config=None):
- self.config = config
+ def __init__(self):
self._tl = threading.local()
def connect(self):
@@ 331,9 330,10 @@ class SQLiteDatabase(Database):
placeholder = '?'
script_func = 'executescript'
- def __init__(self, *args, **kwargs):
- super(SQLiteDatabase, self).__init__(*args, **kwargs)
+ def __init__(self, path):
+ super(SQLiteDatabase, self).__init__()
self._row_types = {}
+ self._path = path
def _row_factory(self, cursor, row):
try:
@@ 345,7 345,7 @@ class SQLiteDatabase(Database):
return row_type._make(row)
def connect(self):
- self._tl.connection = sqlite3.connect(self.config['path'])
+ self._tl.connection = sqlite3.connect(self._path)
self._tl.connection.row_factory = self._row_factory
self._tl.connection.isolation_level = None
@@ 379,14 379,17 @@ class PostgresDatabase(Database):
placeholder = '%s'
schema_separator_char = '.'
- def __init__(self, *args, **kwargs):
+ def __init__(self, host, user, dbname):
if isinstance(psycopg2, ImportError):
raise psycopg2
- super(PostgresDatabase, self).__init__(*args, **kwargs)
+ super(PostgresDatabase, self).__init__()
+ self._host = host
+ self._user = user
+ self._dbname = dbname
def connect(self):
- self._tl.connection = psycopg2.connect(host=self.config['host'],
- database=self.config['database'], user=self.config['user'])
+ self._tl.connection = psycopg2.connect(host=self._host,
+ user=self._user, database=self._dbname)
self._tl.connection.cursor_factory = NamedTupleCursor
self._tl.connection.autocommit = True
@@ 600,7 600,7 @@ class SqliteDatabaseTest(AbstractDatabas
SERIAL_KEY_TYPE = 'INTEGER PRIMARY KEY ASC'
def setUp(self):
- self.db = SQLiteDatabase(config={'path': ':memory:'})
+ self.db = SQLiteDatabase(':memory:')
class PostgresDatabaseTest(AbstractDatabaseTest, unittest.TestCase):
@@ 665,8 665,7 @@ class PostgresDatabaseTest(AbstractDatab
def setUp(self):
- self.db = PostgresDatabase(config={'host': self.pgtc,
- 'database': 'deeno', 'user': os.environ['USER']})
+ self.db = PostgresDatabase(self.pgtc, os.environ['USER'], 'deeno')
def tearDown(self):