radim94 commented on a change in pull request #14105:
URL: https://github.com/apache/airflow/pull/14105#discussion_r571622484



##########
File path: airflow/providers/google/leveldb/hooks/leveldb.py
##########
@@ -0,0 +1,102 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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.
+"""Hook for Level DB"""
+import plyvel
+from plyvel import DB
+
+from airflow.exceptions import AirflowException
+from airflow.hooks.base import BaseHook
+
+
+class LevelDBHookException(AirflowException):
+    """Exception specific for LevelDB"""
+
+
+class LevelDBHook(BaseHook):
+    """
+    Plyvel Wrapper to Interact With LevelDB Database
+    LevelDB Connection Documentation https://plyvel.readthedocs.io/en/latest/
+    """
+
+    conn_name_attr = 'leveldb_conn_id'
+    default_conn_name = 'leveldb_default'
+    conn_type = 'leveldb'
+    hook_name = 'LevelDB'
+
+    def __init__(self, conn_id: str = default_conn_name, *args, **kwargs):
+        super().__init__()
+        self.leveldb_conn_id = conn_id
+        self.connection = self.get_connection(conn_id)
+        self.db = None
+
+    def __exit__(self):
+        self.close_conn()

Review comment:
       I used MongoHook and RedisHook as examples, only now I better understand 
details of implementation for hook. Thanks for comment, I will delete this 
magic method, fixes are in progress.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to