airflow-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gabriel Llobera (JIRA)" <>
Subject [jira] [Created] (AIRFLOW-27) MsSqlOperator: ERROR - 'pymssql.Connection' object attribute 'autocommit' is read-only
Date Mon, 02 May 2016 08:50:12 GMT
Gabriel Llobera created AIRFLOW-27:

             Summary: MsSqlOperator:  ERROR - 'pymssql.Connection' object attribute 'autocommit'
is read-only
                 Key: AIRFLOW-27
             Project: Apache Airflow
          Issue Type: Bug
         Environment: Ubuntu 14.04.4 LTS
            Reporter: Gabriel Llobera

I have the following code:
from airflow import DAG
from airflow.operators import MsSqlOperator
from datetime import datetime, timedelta

args = {
    'owner': 'airflow',
    'depends_on_past': True,
    'start_date': datetime(2016, 4, 6, 1, 0),
    'email': [''],
    'email_on_failure': True,
    'email_on_retry': True,
    'retries': 1,
    'retry_delay': timedelta(minutes=5),
    'execution_timeout': timedelta(hours=23),
    'priority_weight': 10

dag = DAG('dag_name', default_args=args, schedule_interval='0 1 * * *')

t_generate_metadata_csv = MsSqlOperator(task_id='task_id',
                                        sql='SELECT a FROM b',

And I'm getting this error:
ERROR - 'pymssql.Connection' object attribute 'autocommit' is read-only
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/airflow/", line 1064, in run
    result = task_copy.execute(context=context)
  File "/usr/local/lib/python2.7/dist-packages/airflow/operators/", line
34, in execute, parameters=self.parameters)
  File "/usr/local/lib/python2.7/dist-packages/airflow/hooks/", line 101, in
    self.set_autocommit(conn, autocommit)
  File "/usr/local/lib/python2.7/dist-packages/airflow/hooks/", line 115, in
    conn.autocommit = autocommit

Looking at the source code I think I might know why it fails (I have added links to the referenced
lines in the source code). In dbapi_hook, [if the connection supports autocommit|]
then we call set_autocommit, which does [conn.autocommit = autocommit|].

MsSqlHook has [supports_autocommit set to true|],
but the connection type it uses, which is pymssql has no autocommit attribute. [Instead it
is called _autocommit|]
and [autocommit is defined as a function|]
to turn autocommit on or off.

So it seems that the error is caused by trying to set the conn.autocommit to a boolean value
when it is not actually a variable but a function. This seems to be supported by this [link|]
where someone causes the same error by trying to assign a value to a function.

This message was sent by Atlassian JIRA

View raw message