@@ -87,18 +87,18 @@ def _parse(self, e):
87
87
return str (e )
88
88
89
89
def execute (self , text , ** params ):
90
- """
91
- Execute a SQL statement.
92
- """
90
+ """Execute a SQL statement."""
91
+
93
92
class UserDefinedType (sqlalchemy .TypeDecorator ):
94
- """
95
- Add support for expandable values, a la https://bitbucket.org/zzzeek/sqlalchemy/issues/3953/expanding-parameter.
96
- """
93
+ """Add support for expandable values, a la https://github.com/sqlalchemy/sqlalchemy/issues/3953."""
97
94
95
+ # Required class-level attribute
96
+ # https://docs.sqlalchemy.org/en/latest/core/custom_types.html#sqlalchemy.types.TypeDecorator
98
97
impl = sqlalchemy .types .UserDefinedType
99
98
100
99
def process_literal_param (self , value , dialect ):
101
100
"""Receive a literal parameter value to be rendered inline within a statement."""
101
+
102
102
def process (value ):
103
103
"""Render a literal value, escaping as needed."""
104
104
@@ -147,8 +147,7 @@ def process(value):
147
147
else :
148
148
return process (value )
149
149
150
- # Allow only one statement at a time
151
- # SQLite does not support executing many statements
150
+ # Allow only one statement at a time, since SQLite doesn't support multiple
152
151
# https://docs.python.org/3/library/sqlite3.html#sqlite3.Cursor.execute
153
152
if len (sqlparse .split (text )) > 1 :
154
153
raise RuntimeError ("too many statements at once" )
@@ -234,10 +233,10 @@ def process(value):
234
233
def _connect (dbapi_connection , connection_record ):
235
234
"""Enables foreign key support."""
236
235
237
- # Ensure backend is sqlite
236
+ # If back end is sqlite
238
237
if type (dbapi_connection ) is sqlite3 .Connection :
239
- cursor = dbapi_connection .cursor ()
240
238
241
239
# Respect foreign key constraints by default
240
+ cursor = dbapi_connection .cursor ()
242
241
cursor .execute ("PRAGMA foreign_keys=ON" )
243
242
cursor .close ()
0 commit comments