Async and Sync SQL Engine for Python, with support for PostgreSQL, MySQL, SQLite and Microsoft SQL Server.
Project description
PySQLXEngine
PySQLXEngine, a fast and minimalist SQL engine
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 Async and Sync SQL engine. Currently this lib have supports async and sync programming.
The PySQLXEngine was created and thought to be minimalistic, but very efficient. The core is write in Rust, making communication between database and Python more efficient.
Database Support:
SQLite
PostgreSQL
MySQL
Microsoft SQL Server
OS Support:
Linux
MacOS
Windows
Installation
UV
$ uv add pysqlx-engine
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)
]
Project details
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
Built Distribution
File details
Details for the file pysqlx_engine-0.3.2.tar.gz
.
File metadata
- Download URL: pysqlx_engine-0.3.2.tar.gz
- Upload date:
- Size: 26.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.10.2 Linux/6.5.0-1025-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 37f71533f1d8632edeba00f559243008214dd36bb28bc707d25132a1d1768a41 |
|
MD5 | 451e26247136dfd714e5bfd7b5925184 |
|
BLAKE2b-256 | 079f3f7cdfe3be12c1640e47da65d9969cfb3c47130c8f85a02c2b18224df4d2 |
File details
Details for the file pysqlx_engine-0.3.2-py3-none-any.whl
.
File metadata
- Download URL: pysqlx_engine-0.3.2-py3-none-any.whl
- Upload date:
- Size: 33.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.10.2 Linux/6.5.0-1025-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d5740a09ea821a39949bf8075fdd99b790816a24e9c033ff1622aade9f114116 |
|
MD5 | 5df836ec2c6499f2fdc73762f868499a |
|
BLAKE2b-256 | 2cb16a069602c7285e28b878a78e716b42e8d59470e34ee19e17ff1666aa46d7 |