Skip to main content

aio_ormsql

Simple asynchronous MySQL ORM class.

Easy install

pip3 install aio_ormsql

Required

  • pip3 install asyncio aiomysql
  • Python 3.6+

Example usage

  1. Do imports:
from aio_ormsql.db import DataBase
from aio_ormsql.classes Table, Column, WHERE

Where:

  • DataBase - class for working with MySQL
  • Table - class for creating a new table
  • Column - class for creating a columns
  • WHERE - class for creating where statements
  1. Follow examples ans see their output:

Examples

Creating table

tbl = Table(
    'tests',
    Column('id', int),
    Column('tname', str)
)

Connection to database

db = DataBase('admin', 'admin', 'tests')
await db.connect()

Simple WHERE statement

where = WHERE(
    tbl.tname == 'admin'
)
print(where)

# Output:
# WHERE `tname`='admin'

Another WHERE statement

where2 = WHERE(
    (tbl.id >= 20) | (tbl.tname == 'admin')
)
print(where2)

# Output:
# WHERE `id`>=20 OR `tname`='admin'

SELECT example

statement = await db.select(
    [tbl.id, tbl.tname], where=where, table=tbl, back=True
)
print(statement)

# Output:
# SELECT DISTINCT `id`, `tname` FROM `tests` WHERE `tname`='admin'

SELECT example 2

statement2 = await db.select(
    [tbl.id, tbl.tname], False, where2, table=tbl, back=True
)
print(statement2)

# Output:
# SELECT`id`, `tname` FROM `tests` WHERE `id`>=20 OR `tname`='admin'

INSERT example

statement3 = await db.insert(
    {
        tbl.id: 123,
        tbl.tname: 'Johan'
    },
    tbl,
    back=True
)
print(statement3)

# Output:
# INSERT INTO `tests` (`id`, `tname`) VALUES (123, 'Johan')

INSERT example 2

statement4 = await db.update(
    {
        tbl.id: '123',
        tbl.tname: 'Admin'
    },
    WHERE(tbl.tname == 'Johan'),
    tbl,
    back=True
)
print(statement4)

# Output:
# UPDATE `tests` SET `id`=123, `tname`='Admin' WHERE `tname`='Johan'

Working with large DB

array = db.fetch_gen(await db.select(
    [tbl.id, tbl.tname], back=True
))

async for item in array:
    print('New pair:', item)
    # And you can see row-by-row output

Closing connection and wait for completing tasks

await db.close()

Metadata

Release files for aio-ormsql 0.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aio-ormsql 0.0.5
File Size Uploaded Provenance Actions
aio_ormsql-0.0.5.tar.gz 4.7 kB Without provenance Details for aio_ormsql-0.0.5.tar.gz

Release files / aio_ormsql-0.0.5.tar.gz

Download URL aio_ormsql-0.0.5.tar.gz
Size 4.7 kB
Tags Source
SHA-256 checksum
How to use checksums
93380358dbb502c599367f68a99d6aef4974ecbd296bd95e2b8951ca160219f5
BLAKE2b-256 checksum
How to use checksums
6df39979f047351c503f531ae392f6e486bce23a7f3ebae960a2cc0f378553b9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.8

Security for aio-ormsql 0.0.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.5 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page