Asynchronous RabbitMQ consumer job library for PostgreSQL
Project description
rabbitmq2psql-as-json
rabbitmq2psql-as-json is ready to use, basic asynchronous RabbitMQ consumer job library for PostgreSQL. It stops when queue is empty, so it can be useful for cron jobs, unit tests, CI/CD environments and production environments has slow datastream.
Usage
import os
import asyncio
from rabbitmq2psql-as-json import consume
if __name__ == '__main__':
config = {
"mq_host": os.environ.get('MQ_HOST'),
"mq_port": int(os.environ.get('MQ_PORT')),
"mq_vhost": os.environ.get('MQ_VHOST'),
"mq_user": os.environ.get('MQ_USER'),
"mq_pass": os.environ.get('MQ_PASS'),
"mq_queue": os.environ.get('MQ_QUEUE'),
"db_host": os.environ.get('DB_HOST'),
"db_port": int(os.environ.get('DB_PORT')),
"db_user": os.environ.get('DB_USER'),
"db_pass": os.environ.get('DB_PASS'),
"db_database": os.environ.get('DB_DATABASE')
}
sql_template = """insert into logs (body) values (%s);"""
loop = asyncio.get_event_loop()
loop.run_until_complete(
consume(loop=loop, consumer_pool_size=10, sql_template=sql_template, config=config)
)
loop.close()
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for rabbitmq2psql_as_json-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 90cc3956327fb7285655e3ecc9cb7da7a4ea1c15bae90b757e81c7afbe50b73c |
|
MD5 | 21eb3c1b1b3e15ae5fa4ffb76375f1b8 |
|
BLAKE2b-256 | f7bed08e8788458ba6ed70680c25be78c4286898e831da548e6ea3b78a2634c1 |