blob: 42659941bb4cc5f4d47444197aa75f31517089e7 [file] [log] [blame]
:py:mod:`airflow.providers.google.leveldb.hooks.leveldb`
========================================================
.. py:module:: airflow.providers.google.leveldb.hooks.leveldb
.. autoapi-nested-parse::
Hook for Level DB
Module Contents
---------------
Classes
~~~~~~~
.. autoapisummary::
airflow.providers.google.leveldb.hooks.leveldb.LevelDBHook
Attributes
~~~~~~~~~~
.. autoapisummary::
airflow.providers.google.leveldb.hooks.leveldb.DB_NOT_INITIALIZED_BEFORE
.. py:data:: DB_NOT_INITIALIZED_BEFORE
:annotation: = The `get_conn` method should be called before!
.. py:exception:: LevelDBHookException
Bases: :py:obj:`airflow.exceptions.AirflowException`
Exception specific for LevelDB
.. py:class:: LevelDBHook(leveldb_conn_id = default_conn_name)
Bases: :py:obj:`airflow.hooks.base.BaseHook`
Plyvel Wrapper to Interact With LevelDB Database
`LevelDB Connection Documentation <https://plyvel.readthedocs.io/en/latest/>`__
.. py:attribute:: conn_name_attr
:annotation: = leveldb_conn_id
.. py:attribute:: default_conn_name
:annotation: = leveldb_default
.. py:attribute:: conn_type
:annotation: = leveldb
.. py:attribute:: hook_name
:annotation: = LevelDB
.. py:method:: get_conn(name = '/tmp/testdb/', create_if_missing = False, **kwargs)
Creates `Plyvel DB <https://plyvel.readthedocs.io/en/latest/api.html#DB>`__
:param name: path to create database e.g. `/tmp/testdb/`)
:param create_if_missing: whether a new database should be created if needed
:param kwargs: other options of creation plyvel.DB. See more in the link above.
:returns: DB
:rtype: plyvel.DB
.. py:method:: close_conn()
Closes connection
.. py:method:: run(command, key, value = None, keys = None, values = None)
Execute operation with leveldb
:param command: command of plyvel(python wrap for leveldb) for DB object e.g.
``"put"``, ``"get"``, ``"delete"``, ``"write_batch"``.
:param key: key for command(put,get,delete) execution(, e.g. ``b'key'``, ``b'another-key'``)
:param value: value for command(put) execution(bytes, e.g. ``b'value'``, ``b'another-value'``)
:param keys: keys for command(write_batch) execution(List[bytes], e.g. ``[b'key', b'another-key'])``
:param values: values for command(write_batch) execution e.g. ``[b'value'``, ``b'another-value']``
:returns: value from get or None
:rtype: Optional[bytes]
.. py:method:: put(key, value)
Put a single value into a leveldb db by key
:param key: key for put execution, e.g. ``b'key'``, ``b'another-key'``
:param value: value for put execution e.g. ``b'value'``, ``b'another-value'``
.. py:method:: get(key)
Get a single value into a leveldb db by key
:param key: key for get execution, e.g. ``b'key'``, ``b'another-key'``
:returns: value of key from db.get
:rtype: bytes
.. py:method:: delete(key)
Delete a single value in a leveldb db by key.
:param key: key for delete execution, e.g. ``b'key'``, ``b'another-key'``
.. py:method:: write_batch(keys, values)
Write batch of values in a leveldb db by keys
:param keys: keys for write_batch execution e.g. ``[b'key', b'another-key']``
:param values: values for write_batch execution e.g. ``[b'value', b'another-value']``