[ 
https://issues.apache.org/jira/browse/AIRFLOW-1068?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Thomas Christie updated AIRFLOW-1068:
-------------------------------------
    Environment: 
OS: Centos 6
pymssql: 2.1.3

  was:OS: Centos 6

    Description: 
After upgrading pymssql started getting the following error when trying to use 
the MSSQL hook.

    [2017-04-04 13:02:27,260] {models.py:1286} ERROR - 'pymssql.Connection' 
object attribute 'autocommit' is read-only
    Traceback (most recent call last):
      File 
"/home/jobrunner/.virtualenvs/airflow/lib/python3.5/site-packages/airflow/models.py",
 line 1245, in run
        result = task_copy.execute(context=context)
      File 
"/home/jobrunner/.virtualenvs/airflow/lib/python3.5/site-packages/airflow/operators/mssql_operator.py",
 line 34, in execute
        hook.run(self.sql, parameters=self.parameters)
      File 
"/home/jobrunner/.virtualenvs/airflow/lib/python3.5/site-packages/airflow/hooks/dbapi_hook.py",
 line 124, in run
        self.set_autocommit(conn, autocommit)
      File 
"/home/jobrunner/.virtualenvs/airflow/lib/python3.5/site-packages/airflow/hooks/dbapi_hook.py",
 line 138, in set_autocommit
        conn.autocommit = autocommit
    AttributeError: 'pymssql.Connection' object attribute 'autocommit' is 
read-only

I looked at the dbapi_hook.py file and this is the offending line:

    def set_autocommit(self, conn, autocommit):
        conn.autocommit = autocommit

Changing the line to:

conn.autocommit(autocommit)

seems to work.  From what I understand, autocommit was a getter/setter method 
in pymssql versions <2.0.0.  Maybe they've reverted the behavior?

> Autocommit error with Airflow v1.7.1.3 and pymssql v2.1.3
> ---------------------------------------------------------
>
>                 Key: AIRFLOW-1068
>                 URL: https://issues.apache.org/jira/browse/AIRFLOW-1068
>             Project: Apache Airflow
>          Issue Type: Bug
>          Components: db, hooks
>    Affects Versions: Airflow 1.7.1.3
>         Environment: OS: Centos 6
> pymssql: 2.1.3
>            Reporter: Thomas Christie
>
> After upgrading pymssql started getting the following error when trying to 
> use the MSSQL hook.
>     [2017-04-04 13:02:27,260] {models.py:1286} ERROR - 'pymssql.Connection' 
> object attribute 'autocommit' is read-only
>     Traceback (most recent call last):
>       File 
> "/home/jobrunner/.virtualenvs/airflow/lib/python3.5/site-packages/airflow/models.py",
>  line 1245, in run
>         result = task_copy.execute(context=context)
>       File 
> "/home/jobrunner/.virtualenvs/airflow/lib/python3.5/site-packages/airflow/operators/mssql_operator.py",
>  line 34, in execute
>         hook.run(self.sql, parameters=self.parameters)
>       File 
> "/home/jobrunner/.virtualenvs/airflow/lib/python3.5/site-packages/airflow/hooks/dbapi_hook.py",
>  line 124, in run
>         self.set_autocommit(conn, autocommit)
>       File 
> "/home/jobrunner/.virtualenvs/airflow/lib/python3.5/site-packages/airflow/hooks/dbapi_hook.py",
>  line 138, in set_autocommit
>         conn.autocommit = autocommit
>     AttributeError: 'pymssql.Connection' object attribute 'autocommit' is 
> read-only
> I looked at the dbapi_hook.py file and this is the offending line:
>     def set_autocommit(self, conn, autocommit):
>         conn.autocommit = autocommit
> Changing the line to:
> conn.autocommit(autocommit)
> seems to work.  From what I understand, autocommit was a getter/setter method 
> in pymssql versions <2.0.0.  Maybe they've reverted the behavior?



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to