Skip to content

xRedCrystalx/aiomaria

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

aiomaria

Asynchronous wrapper for MariaDB library (mariadb-connector-python) written in python.

Important

This library is still under early development. For any bugs, please create an issue here.

Example

Basic connection

import aiomaria, asyncio

credentials = {
    "host": "localhost",
    "port": 3306,
    "user": "user",
    "password": "password",
    "database": "database"
}

async def main() -> None:
    con: aiomaria.Connection = await aiomaria.connect(**credentials)
    print(con.server_info)
    await con.close()

asyncio.run(main())

Connection pool

# `pool_name` param will trigger pool creation
pool: aiomaria.Connection = await aiomaria.connect(**credentials, pool_name="test")

Note

.connect() will always return aiomaria.Connection. Pool can be accessed from the aiomaria._CONNECTION_POOLS dictionary with its name.

With async context manager

async with aiomaria.Connection(**credentials) as con:
    print(con.server_info)

# or

async with aiomaria.ConnectionPool(**credentials, pool_name="test") as pool:
    con: aiomaria.Connection = await pool.get_connection()
    print(con.server_info)

Caution

Due to how wrapper works, mariadb library will no longer work once the aiomaria is imported. This is due to monkeypatching at runtime and will hopefully be resolved in the future.

Installation

pip install aiomaria

For operating systems other than MS Windows, some binaries are required. See MariaDB connector installation.

Licence

MIT License

About

Asynchronous wrapper for MariaDB library (mariadb-connector-python) written in python.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages