数据库¶
PasswordVault
¶
Password vault manager that provides access to password vault implementations.
Caches vault instances for performance.
Source code in aloha/db/base.py
get_vault(vault_type=None, vault_config=None, **kwargs)
staticmethod
¶
Get a password vault instance.
Supports multiple vault types: - 'plain' or 'aes': AES-based vault (default fallback) - 'cyberark': CyberArk vault - Other/None: Dummy vault (plain text)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vault_type
|
str | None
|
Type of vault to use (overrides config) |
None
|
vault_config
|
dict | None
|
Vault configuration dictionary |
None
|
args
|
Additional arguments |
required | |
kwargs
|
Additional keyword arguments |
{}
|
Returns:
| Type | Description |
|---|---|
BaseVault
|
Vault instance implementing BaseVault interface |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If CyberArk vault is requested but config is missing |
Source code in aloha/db/base.py
main()
¶
Command-line tool to decrypt passwords from config.
Usage: python -m aloha.db.base
Source code in aloha/db/base.py
DuckDB connection helpers.
DuckOperator
¶
Create and use a DuckDB connection through SQLAlchemy.
Source code in aloha/db/duckdb.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | |
connection_str
property
¶
Return a human-readable connection string.
__init__(db_config, **kwargs)
¶
Build a DuckDB engine, creating the database file if necessary.
Source code in aloha/db/duckdb.py
execute_query(sql, *args, **kwargs)
¶
Execute a SQL statement and return the cursor result.
Source code in aloha/db/duckdb.py
ElasticSearchOperator
¶
Create and use an Elasticsearch client with optional index helpers.
Source code in aloha/db/elasticsearch.py
__init__(config, index_config=None)
¶
Build the client and optionally load the index configuration.
Source code in aloha/db/elasticsearch.py
build_index(index_name=None, index_config=None, raise_if_exist=False)
¶
Create the index if it does not already exist.
Source code in aloha/db/elasticsearch.py
insert(doc, index_name=None, index_type=None, id=None)
¶
msearch(body)
¶
put_mapping(index_name=None, index_type=None, index_config=None)
¶
Apply a mapping definition to the current index.
Source code in aloha/db/elasticsearch.py
search(query, index_name=None, index_type=None)
¶
Kafka connection helpers.
KafkaOperator
¶
Create Kafka admin, producer, and consumer clients.
Source code in aloha/db/kafka.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | |
__init__(kafka_config)
¶
Parameter reference: https://github.com/edenhill/librdkafka/blob/master/CONFIGURATION.md
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kafka_config
|
host = [ {host: kafka_server_1, port: 9092} ] |
required |
Source code in aloha/db/kafka.py
admin_client(*args, **kwargs)
¶
consumer_generator(topics_subscribe, group_id=None, poll_timeout=1.0, *args, **kwargs)
¶
Yield decoded messages from the subscribed Kafka topics.
Source code in aloha/db/kafka.py
create_topic(topic, num_partitions=3, replication_factor=1, *args, **kwargs)
¶
Create a Kafka topic and wait for the broker response.
Source code in aloha/db/kafka.py
producer_deliver(topic, generator, func_callback=None, *args, **kwargs)
¶
Stream messages from an iterator into a Kafka topic.
Source code in aloha/db/kafka.py
MongoDB connection helpers.
MongoOperator(config)
¶
Return a cached MongoDB operation wrapper for the given config.
Source code in aloha/db/mongo.py
MySQL connection helpers.
MySqlOperator
¶
Create and use a SQLAlchemy-backed MySQL connection.
Source code in aloha/db/mysql.py
connection_str
property
¶
Return a human-readable connection string.
__init__(db_config, **kwargs)
¶
Build a connection pool from the provided database config.
Source code in aloha/db/mysql.py
execute_query(sql, *args, **kwargs)
¶
Oracle DB connection helpers.
OracledbOperator
¶
Create and use a SQLAlchemy-backed Oracle connection.
Source code in aloha/db/oracle.py
connection_str
property
¶
Return a human-readable connection string.
__init__(db_config, **kwargs)
¶
Build an Oracle connection pool from the provided config.
Source code in aloha/db/oracle.py
execute_query(sql, *args, **kwargs)
¶
Execute a SQL statement and return the cursor result.
PostgreSQL connection helpers.
PostgresOperator
¶
Create and use a SQLAlchemy-backed PostgreSQL connection.
Source code in aloha/db/postgres.py
connection_str
property
¶
Return a human-readable connection string.
__init__(db_config, **kwargs)
¶
Build a PostgreSQL connection pool from the database config.
Source code in aloha/db/postgres.py
execute_query(sql, *args, **kwargs)
¶
Execute a SQL statement and return the cursor result.
Redis connection helpers.
RedisOperator
¶
Create Redis connections with version-checked redis-py.
Source code in aloha/db/redis.py
connection_cluster
property
¶
Return a Redis Cluster client.
connection_generic
property
¶
Return a standard Redis client.
__init__(config)
¶
Normalize Redis connection settings and build connection metadata.
Source code in aloha/db/redis.py
SQLite connection helpers.
SqliteOperator
¶
Create and use a SQLAlchemy-backed SQLite connection.
Source code in aloha/db/sqlite.py
connection_str
property
¶
Return the SQLAlchemy connection URL used by the engine.
__init__(db_config, **kwargs)
¶
Build a SQLite or SQLCipher engine from the provided config.