]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Update connections.rst 8075/head
authorJosep Pascual Badia <joseppascualbadia@gmail.com>
Mon, 30 May 2022 14:35:35 +0000 (16:35 +0200)
committerGitHub <noreply@github.com>
Mon, 30 May 2022 14:35:35 +0000 (16:35 +0200)
Keep cursor_obj variable name

doc/build/faq/connections.rst

index 59db00c37b2833d35c239afb42ba39d7f4032667..9450dfdfa037af29b618a5179b46eae276043872 100644 (file)
@@ -255,14 +255,14 @@ statement executions::
 
 
   def reconnecting_engine(engine, num_retries, retry_interval):
-      def _run_with_retries(fn, context, cursor, statement, *arg, **kw):
+      def _run_with_retries(fn, context, cursor_obj, statement, *arg, **kw):
           for retry in range(num_retries + 1):
               try:
-                  fn(cursor, statement, context=context, *arg)
+                  fn(cursor_obj, statement, context=context, *arg)
               except engine.dialect.dbapi.Error as raw_dbapi_err:
                   connection = context.root_connection
                   if engine.dialect.is_disconnect(
-                      raw_dbapi_err, connection, cursor
+                      raw_dbapi_err, connection, cursor_obj
                   ):
                       if retry > num_retries:
                           raise
@@ -281,7 +281,7 @@ statement executions::
                               trans.rollback()
 
                       time.sleep(retry_interval)
-                      context.cursor = cursor = connection.connection.cursor()
+                      context.cursor = cursor_obj = connection.connection.cursor()
                   else:
                       raise
               else:
@@ -290,15 +290,15 @@ statement executions::
       e = engine.execution_options(isolation_level="AUTOCOMMIT")
 
       @event.listens_for(e, "do_execute_no_params")
-      def do_execute_no_params(cursor, statement, context):
+      def do_execute_no_params(cursor_obj, statement, context):
           return _run_with_retries(
-              context.dialect.do_execute_no_params, context, cursor, statement
+              context.dialect.do_execute_no_params, context, cursor_obj, statement
           )
 
       @event.listens_for(e, "do_execute")
-      def do_execute(cursor, statement, parameters, context):
+      def do_execute(cursor_obj, statement, parameters, context):
           return _run_with_retries(
-              context.dialect.do_execute, context, cursor, statement, parameters
+              context.dialect.do_execute, context, cursor_obj, statement, parameters
           )
 
       return e