@@ -87,18 +87,18 @@ def _parse(self, e):
8787 return str (e )
8888
8989 def execute (self , text , ** params ):
90- """
91- Execute a SQL statement.
92- """
90+ """Execute a SQL statement."""
91+
9392 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."""
9794
95+ # Required class-level attribute
96+ # https://docs.sqlalchemy.org/en/latest/core/custom_types.html#sqlalchemy.types.TypeDecorator
9897 impl = sqlalchemy .types .UserDefinedType
9998
10099 def process_literal_param (self , value , dialect ):
101100 """Receive a literal parameter value to be rendered inline within a statement."""
101+
102102 def process (value ):
103103 """Render a literal value, escaping as needed."""
104104
@@ -147,8 +147,7 @@ def process(value):
147147 else :
148148 return process (value )
149149
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
152151 # https://docs.python.org/3/library/sqlite3.html#sqlite3.Cursor.execute
153152 if len (sqlparse .split (text )) > 1 :
154153 raise RuntimeError ("too many statements at once" )
@@ -234,10 +233,10 @@ def process(value):
234233def _connect (dbapi_connection , connection_record ):
235234 """Enables foreign key support."""
236235
237- # Ensure backend is sqlite
236+ # If back end is sqlite
238237 if type (dbapi_connection ) is sqlite3 .Connection :
239- cursor = dbapi_connection .cursor ()
240238
241239 # Respect foreign key constraints by default
240+ cursor = dbapi_connection .cursor ()
242241 cursor .execute ("PRAGMA foreign_keys=ON" )
243242 cursor .close ()
0 commit comments