8
8
import sys
9
9
import warnings
10
10
11
+
11
12
class SQL (object ):
12
13
"""Wrap SQLAlchemy to provide a simple SQL API."""
13
14
@@ -23,7 +24,7 @@ def __init__(self, url, **kwargs):
23
24
24
25
# log statements to standard error
25
26
logging .basicConfig (level = logging .DEBUG )
26
- self .logger = logging .getLogger (__name__ )
27
+ self .logger = logging .getLogger ("cs50" )
27
28
28
29
# create engine, raising exception if back end's module not installed
29
30
self .engine = sqlalchemy .create_engine (url , ** kwargs )
@@ -36,7 +37,9 @@ class UserDefinedType(sqlalchemy.TypeDecorator):
36
37
"""
37
38
Add support for expandable values, a la https://bitbucket.org/zzzeek/sqlalchemy/issues/3953/expanding-parameter.
38
39
"""
40
+
39
41
impl = sqlalchemy .types .UserDefinedType
42
+
40
43
def process_literal_param (self , value , dialect ):
41
44
"""Receive a literal parameter value to be rendered inline within a statement."""
42
45
def process (value ):
@@ -109,7 +112,8 @@ def process(value):
109
112
110
113
# bind parameters before statement reaches database, so that bound parameters appear in exceptions
111
114
# http://docs.sqlalchemy.org/en/latest/core/sqlelement.html#sqlalchemy.sql.expression.text
112
- statement = statement .bindparams (sqlalchemy .bindparam (key , value = value , type_ = UserDefinedType ()))
115
+ statement = statement .bindparams (sqlalchemy .bindparam (
116
+ key , value = value , type_ = UserDefinedType ()))
113
117
114
118
# stringify bound parameters
115
119
# http://docs.sqlalchemy.org/en/latest/faq/sqlexpressions.html#how-do-i-render-sql-expressions-as-strings-possibly-with-bound-parameters-inlined
0 commit comments