Skip to main content

Async and Sync SQL Engine for Python, with support for MySQL, PostgreSQL, SQLite and Microsoft SQL Server.

Project description

PySQLXEngine

PySQLXEngine Logo

PySQLXEngine, a fast and minimalist SQL engine

CI Coverage Package version Supported Python versions Downloads


Documentation: https://carlos-rian.github.io/pysqlx-engine/

Source Code: https://github.com/carlos-rian/pysqlx-engine


PySQLXEngine supports the option of sending Raw SQL to your database.

The PySQLXEngine is a minimalist SQL Engine.

The PySQLXEngine was created and thought to be minimalistic, but very efficient. The core is write in Rust, making communication between Databases and Python more efficient.

All SQL executed using PySQLXEngine is atomic; only one instruction is executed at a time. Only the first one will be completed if you send an Insert and a select. This is one of the ways to handle SQL ingestion. As of version 0.2.0, PySQLXEngine supports transactions, where you can control BEGIN, COMMIT, ROLLBACK , ISOLATION LEVEL, etc. as you wish.

NOTE: Minimalism is not the lack of something, but having exactly what you need. PySQLXEngine aims to expose an easy interface for you to communicate with the database in a simple, intuitive way and with good help through documentation, autocompletion, typing, and good practices.


Database Support:

OS Support:

Installation

PIP

$ pip install pysqlx-engine

Poetry

$ poetry add pysqlx-engine

Async Example

Create a main.py file and add the code examples below.

from pysqlx_engine import PySQLXEngine

async def main():
    db = PySQLXEngine(uri="sqlite:./db.db")
    await db.connect()

    await db.execute(sql="""
        CREATE TABLE IF NOT EXISTS users (
            id INTEGER PRIMARY KEY, 
            name TEXT, 
            age INT
        )
    """)
    await db.execute(sql="INSERT INTO users (name, age) VALUES ('Rian', '28')")
    await db.execute(sql="INSERT INTO users (name, age) VALUES ('Carlos', '29')")

    rows = await db.query(sql="SELECT * FROM users")

    print(rows)

import asyncio
asyncio.run(main())

Sync Example

Create a main.py file and add the code examples below.

from pysqlx_engine import PySQLXEngineSync

def main():
    db = PySQLXEngineSync(uri="sqlite:./db.db")
    db.connect()

    db.execute(sql="""
        CREATE TABLE IF NOT EXISTS users (
            id INTEGER PRIMARY KEY, 
            name TEXT, 
            age INT
        )
    """)
    db.execute(sql="INSERT INTO users (name, age) VALUES ('Rian', '28')")
    db.execute(sql="INSERT INTO users (name, age) VALUES ('Carlos', '29')")

    rows = db.query(sql="SELECT * FROM users")

    print(rows)

# running the code
main()

Running the code using the terminal

$ python3 main.py

Output

[
    BaseRow(id=1, name='Rian', age=28),  
    BaseRow(id=2, name='Carlos', age=29)
]

Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pysqlx_engine-0.3.0b1.tar.gz (29.2 kB view details)

Uploaded Source

Built Distribution

pysqlx_engine-0.3.0b1-py3-none-any.whl (35.6 kB view details)

Uploaded Python 3

File details

Details for the file pysqlx_engine-0.3.0b1.tar.gz.

File metadata

  • Download URL: pysqlx_engine-0.3.0b1.tar.gz
  • Upload date:
  • Size: 29.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.10.2 Linux/6.8.0-1015-azure

File hashes

Hashes for pysqlx_engine-0.3.0b1.tar.gz
Algorithm Hash digest
SHA256 a19ea62a83138d20727cac0f354b256f26f38d0cbcaacd36c445194516062531
MD5 42e134c8d9fd8b58c01a6395af202e74
BLAKE2b-256 89416a0ec74337373c0ee687c95b63e422f33ecf1be42c71b2ab898bfd983d52

See more details on using hashes here.

File details

Details for the file pysqlx_engine-0.3.0b1-py3-none-any.whl.

File metadata

  • Download URL: pysqlx_engine-0.3.0b1-py3-none-any.whl
  • Upload date:
  • Size: 35.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.10.2 Linux/6.8.0-1015-azure

File hashes

Hashes for pysqlx_engine-0.3.0b1-py3-none-any.whl
Algorithm Hash digest
SHA256 135e93b25cbda31bd5c54b2f9f60fb7e9f9d4751b6562dda397bc6ce176fc0c8
MD5 3b5bae9ad1cd1dd21441fe1bb5c1dea5
BLAKE2b-256 4ebcd71249be16af808c92c9cd83c0b6a5ce63d3870d8fbbcdd75210619e5c0c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page