Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 1A64B200A01 for ; Tue, 3 May 2016 17:26:21 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 19CEF1609F4; Tue, 3 May 2016 17:26:21 +0200 (CEST) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 6621F1609A9 for ; Tue, 3 May 2016 17:26:20 +0200 (CEST) Received: (qmail 98902 invoked by uid 500); 3 May 2016 15:26:19 -0000 Mailing-List: contact commits-help@airflow.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@airflow.incubator.apache.org Delivered-To: mailing list commits@airflow.incubator.apache.org Received: (qmail 98893 invoked by uid 99); 3 May 2016 15:26:19 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 May 2016 15:26:19 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 3C66BC015A for ; Tue, 3 May 2016 15:26:19 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -3.221 X-Spam-Level: X-Spam-Status: No, score=-3.221 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-0.001] autolearn=disabled Received: from mx2-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id EitLcDyDL2D6 for ; Tue, 3 May 2016 15:26:16 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx2-lw-eu.apache.org (ASF Mail Server at mx2-lw-eu.apache.org) with SMTP id 5347C60E03 for ; Tue, 3 May 2016 15:26:15 +0000 (UTC) Received: (qmail 96938 invoked by uid 99); 3 May 2016 15:26:13 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 May 2016 15:26:13 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id DC68C2C1F5D for ; Tue, 3 May 2016 15:26:12 +0000 (UTC) Date: Tue, 3 May 2016 15:26:12 +0000 (UTC) From: "Chris Riccomini (JIRA)" To: commits@airflow.incubator.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Resolved] (AIRFLOW-27) MsSqlOperator: ERROR - 'pymssql.Connection' object attribute 'autocommit' is read-only MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Tue, 03 May 2016 15:26:21 -0000 [ https://issues.apache.org/jira/browse/AIRFLOW-27?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Chris Riccomini resolved AIRFLOW-27. ------------------------------------ Resolution: Fixed > MsSqlOperator: ERROR - 'pymssql.Connection' object attribute 'autocommit' is read-only > --------------------------------------------------------------------------------------- > > Key: AIRFLOW-27 > URL: https://issues.apache.org/jira/browse/AIRFLOW-27 > Project: Apache Airflow > Issue Type: Bug > Environment: Ubuntu 14.04.4 LTS > Reporter: Gabriel Llobera > Assignee: Gabriel Llobera > Labels: newbie > Original Estimate: 0.5h > Remaining Estimate: 0.5h > > I have the following code: > {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': ['example@email.com'], > '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', > mssql_conn_id='mssql_conn', > dag=dag) > {code} > And I'm getting this error: > {code} > ERROR - 'pymssql.Connection' object attribute 'autocommit' is read-only > Traceback (most recent call last): > File "/usr/local/lib/python2.7/dist-packages/airflow/models.py", line 1064, in run > result = task_copy.execute(context=context) > File "/usr/local/lib/python2.7/dist-packages/airflow/operators/mssql_operator.py", line 34, in execute > hook.run(self.sql, parameters=self.parameters) > File "/usr/local/lib/python2.7/dist-packages/airflow/hooks/dbapi_hook.py", line 101, in run > self.set_autocommit(conn, autocommit) > File "/usr/local/lib/python2.7/dist-packages/airflow/hooks/dbapi_hook.py", line 115, in set_autocommit > conn.autocommit = autocommit > {code} > 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|https://github.com/airbnb/airflow/blob/master/airflow/hooks/dbapi_hook.py#L123] then we call set_autocommit, which does [conn.autocommit = autocommit|https://github.com/airbnb/airflow/blob/master/airflow/hooks/dbapi_hook.py#L138]. > MsSqlHook has [supports_autocommit set to true|https://github.com/airbnb/airflow/blob/master/airflow/hooks/mssql_hook.py#L13], but the connection type it uses, which is pymssql has no autocommit attribute. [Instead it is called _autocommit|https://github.com/pymssql/pymssql/blob/f814fd9dedc7cd87fabbe92dfb1b6d19a5ed31a3/src/pymssql.pyx#L209] and [autocommit is defined as a function|https://github.com/pymssql/pymssql/blob/f814fd9dedc7cd87fabbe92dfb1b6d19a5ed31a3/src/pymssql.pyx#L255] 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|http://www.gossamer-threads.com/lists/python/python/514536] where someone causes the same error by trying to assign a value to a function. -- This message was sent by Atlassian JIRA (v6.3.4#6332)