Skip to content

Commit 0760238

Browse files
committed
Add peewee ext
1 parent 37cd734 commit 0760238

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

pycovenantsql/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
threadsafety = 1
1717
apilevel = "2.0"
18-
paramstyle = "pyformat"
18+
paramstyle = "format"
1919

2020

2121
class DBAPISet(frozenset):

pycovenantsql/ext/peewee.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import pycovenantsql
2+
from peewee import Database, ImproperlyConfigured
3+
4+
class CovenantSQLDatabase(Database):
5+
param = '%s'
6+
quote = '``'
7+
def __init__(self, database, **kwargs):
8+
super(CovenantSQLDatabase, self).__init__(database, **kwargs)
9+
10+
def _connect(self, **kwargs):
11+
if pycovenantsql is None:
12+
raise ImproperlyConfigured('pycovenantsql driver not installed!')
13+
conn = pycovenantsql.connect(database=self.database, **self.connect_params)
14+
return conn

0 commit comments

Comments
 (0)