[jira] [Commented] (AIRFLOW-1595) SqliteHook is broken

2018-12-17 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/AIRFLOW-1595?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16723489#comment-16723489
 ] 

ASF GitHub Bot commented on AIRFLOW-1595:
-

stale[bot] closed pull request #2598: [AIRFLOW-1595] Change to construct 
sqlite_hook from connection schema
URL: https://github.com/apache/incubator-airflow/pull/2598
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/airflow/hooks/sqlite_hook.py b/airflow/hooks/sqlite_hook.py
index c241c2ddef..5a9c7e3516 100644
--- a/airflow/hooks/sqlite_hook.py
+++ b/airflow/hooks/sqlite_hook.py
@@ -32,5 +32,5 @@ def get_conn(self):
 Returns a sqlite connection object
 """
 conn = self.get_connection(self.sqlite_conn_id)
-conn = sqlite3.connect(conn.host)
+conn = sqlite3.connect(conn.schema)
 return conn
diff --git a/airflow/utils/db.py b/airflow/utils/db.py
index 35c187ca54..44aa05429d 100644
--- a/airflow/utils/db.py
+++ b/airflow/utils/db.py
@@ -160,7 +160,7 @@ def initdb():
 merge_conn(
 models.Connection(
 conn_id='sqlite_default', conn_type='sqlite',
-host='/tmp/sqlite_default.db'))
+schema='/tmp/sqlite_default.db'))
 merge_conn(
 models.Connection(
 conn_id='http_default', conn_type='http',
diff --git a/tests/hooks/test_sqlite_hook.py b/tests/hooks/test_sqlite_hook.py
new file mode 100644
index 00..de830f09ae
--- /dev/null
+++ b/tests/hooks/test_sqlite_hook.py
@@ -0,0 +1,53 @@
+# -*- coding: utf-8 -*-
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+import mock
+import unittest
+import os
+
+from airflow import settings, models
+from airflow.settings import Session
+from airflow.hooks.sqlite_hook import SqliteHook
+
+
+@unittest.skipIf(not settings.SQL_ALCHEMY_CONN.startswith('sqlite'), 
'SqliteHook won\'t work without backend SQLite. No need to test anything here')
+class TestSqliteHook(unittest.TestCase):
+
+CONN_ID = 'sqlite_hook_test'
+
+@classmethod
+def setUpClass(cls):
+super(TestSqliteHook, cls).setUpClass()
+session = Session()
+
session.query(models.Connection).filter_by(conn_id=cls.CONN_ID).delete()
+session.commit()
+connection = models.Connection(conn_id=cls.CONN_ID, 
uri=settings.SQL_ALCHEMY_CONN)
+session.add(connection)
+session.commit()
+session.close()
+
+def test_sql_hook(self):
+hook = SqliteHook(sqlite_conn_id=self.CONN_ID)
+conn_id, = hook.get_first('SELECT conn_id FROM connection WHERE 
conn_id = :conn_id',
+  {'conn_id': self.CONN_ID})
+self.assertEqual(conn_id, self.CONN_ID)
+
+@classmethod
+def tearDownClass(cls):
+session = Session()
+
session.query(models.Connection).filter_by(conn_id=cls.CONN_ID).delete()
+session.commit()
+session.close()
+super(TestSqliteHook, cls).tearDownClass()


 


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> SqliteHook is broken
> 
>
> Key: AIRFLOW-1595
> URL: https://issues.apache.org/jira/browse/AIRFLOW-1595
> Project: Apache Airflow
>  Issue Type: Bug
>  Components: hooks
>Affects Versions: 1.8.1
>Reporter: Shintaro Murakami
>Priority: Major
>
> SqliteHook is built using the host attribute of connection, but correctly we 
> should use the schema attribute. The path to the DB parsed from the URI is 
> set as schema.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (AIRFLOW-1595) SqliteHook is broken

2018-09-20 Thread Ash Berlin-Taylor (JIRA)


[ 
https://issues.apache.org/jira/browse/AIRFLOW-1595?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16621800#comment-16621800
 ] 

Ash Berlin-Taylor commented on AIRFLOW-1595:


(x-post from Githb) To resurrect an old PR: This PR might make sense, but as it 
is it would break any existing connections that are defined.

The issue is probably around how the connections are created. If for instance I 
create a connection like this `airflow connections -a --conn_id foo --conn_uri 
sqlite://path/to/file.sqlite` then I end up with `{"host": "path", "schema": 
"to/file.sqlite"}` so the fix wouldn't actually help for this case either.

The new options added recently (1.9.0, 1.10.0?) to be able to directly specify 
`--conn_host` probably make this PR as structured not needed, and a doc change 
in the SqliteHook all that is needed. (I'm not expecting you to do that, just 
commenting)

> SqliteHook is broken
> 
>
> Key: AIRFLOW-1595
> URL: https://issues.apache.org/jira/browse/AIRFLOW-1595
> Project: Apache Airflow
>  Issue Type: Bug
>  Components: hooks
>Affects Versions: 1.8.1
>Reporter: Shintaro Murakami
>Priority: Major
>
> SqliteHook is built using the host attribute of connection, but correctly we 
> should use the schema attribute. The path to the DB parsed from the URI is 
> set as schema.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (AIRFLOW-1595) SqliteHook is broken

2017-09-28 Thread Shintaro Murakami (JIRA)

[ 
https://issues.apache.org/jira/browse/AIRFLOW-1595?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16183854#comment-16183854
 ] 

Shintaro Murakami commented on AIRFLOW-1595:


I created PR(https://github.com/apache/incubator-airflow/pull/2598)

> SqliteHook is broken
> 
>
> Key: AIRFLOW-1595
> URL: https://issues.apache.org/jira/browse/AIRFLOW-1595
> Project: Apache Airflow
>  Issue Type: Bug
>  Components: hooks
>Affects Versions: 1.8.1
>Reporter: Shintaro Murakami
>
> SqliteHook is built using the host attribute of connection, but correctly we 
> should use the schema attribute. The path to the DB parsed from the URI is 
> set as schema.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)