Asyncio with phoenixdb
Project description
What is aiophoenixdb
This project is based on the Apache Software Foundation open source project Apache-Phoenixdb project to transform the call implementation of the Avatica protocol in the code from the original synchronous mode to asynchronous call.
Getting started
How to install
pip install aiophoenixdb
How to use
Query sample
import aiophoenixdb
import asyncio
PHOENIX_CONFIG = {
'url': 'http://xxxxxxxxxx',
'user': 'xxx',
'password': 'xxx',
'database': 'xxx'
}
async def query_test():
conn = await aiophoenixdb.connect(**PHOENIX_CONFIG)
async with conn:
async with conn.cursor() as ps:
# need await
await ps.execute("SELECT * FROM xxx WHERE id = ?", parameters=("1", ))
res = await ps.fetchone()
print(res)
# Throw the query coroutine into the event loop to run
asyncio.get_event_loop().run_until_complete(query_test())
Query with DictCursor
import aiophoenixdb
import asyncio
from aiophoenixdb.cursors import DictCursor
PHOENIX_CONFIG = {
'url': 'http://xxxxxxxxxx',
'user': 'xxx',
'password': 'xxx',
'database': 'xxx'
}
async def query_test():
conn = await aiophoenixdb.connect(**PHOENIX_CONFIG)
async with conn:
async with conn.cursor(cursor_factory=DictCursor) as ps:
# need await
await ps.execute("SELECT * FROM xxx WHERE id = ?", parameters=("1", ))
res = await ps.fetchone()
print(res)
# Throw the query coroutine into the event loop to run
asyncio.get_event_loop().run_until_complete(query_test())
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
aiophoenixdb-0.0.6.tar.gz
(34.4 kB
view details)
Built Distribution
File details
Details for the file aiophoenixdb-0.0.6.tar.gz
.
File metadata
- Download URL: aiophoenixdb-0.0.6.tar.gz
- Upload date:
- Size: 34.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
925ffdc173232dc4e153bfded89de494ca5a915dde46f7c6a5903ca6848e68b9
|
|
MD5 |
1e0755510d06ab72d2d030c7ce98bbcf
|
|
BLAKE2b-256 |
d6b399895f7dca70fd5df4c271e8450d8d7484f0e84a58eca68a08e415ae9716
|
File details
Details for the file aiophoenixdb-0.0.6-py3-none-any.whl
.
File metadata
- Download URL: aiophoenixdb-0.0.6-py3-none-any.whl
- Upload date:
- Size: 48.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
fa13297f536dc4b26e4910adb10b30b299d8e574995ec7ddbb701f4d7e6d2c29
|
|
MD5 |
df36fa34382374676bf32f39eee551e9
|
|
BLAKE2b-256 |
934b9b161f740d244f155658180570b1ba9f03564222e54ea38c7c0e68a07cd3
|