Artifex
Typed Python SQLite/PostgreSQL query builder.
This is in early development and may see massive refactor.
Usage
Use artifex functions delete, insert_into, select, update to build a query. Then
call prepare() to get a tuple comprising a list of parameters used in the query and
the query itself. Anywhere a parameter was used in the query will be replaced with ?,
this way the database can handle param binding.
Black Formatted Example
from sql_artifex import Column, Table, and_, join, select
class User(Table):
id = Column()
first = Column()
last = Column()
class Note(Table):
id = Column()
user_id = Column()
value = Column()
sql, params = (
select(
User.id,
User.first,
User.last,
Note.id.as_("note_id"),
Note.value,
)
.from_(
User,
join(Note).on(Note.user_id == User.id),
)
.where(
User.id == 1,
and_(Note.value == "test_note"),
)
.order_by(
Note.value.desc(),
)
).prepare()
assert params == [1, "test_note"]
expected = " ".join(
[
"SELECT",
'"user".id,',
'"user".first,',
'"user".last,',
'"note".id AS note_id,',
'"note".value',
'FROM "user"',
'JOIN "note" ON "note".user_id = "user".id',
'WHERE "user".id = ? AND "note".value = ?',
'ORDER BY "note".value DESC',
]
)
assert sql == expected
Create Table
from sql_artifex import Column, Table
from sql_artifex.types import TEXT, TIMESTAMP, UUID
class User(Table):
id = Column(UUID(), primary=True)
email = Column(TEXT(), unique=True, index=True)
first = Column(TEXT())
last = Column(TEXT())
verified_at = Column(TIMESTAMP(with_time_zone=True))
User.table_set_unique_together(User.fist, User.last)
print(User.table_get_create())
Prints:
CREATE TABLE IF NOT EXISTS "user" (
"id" UUID PRIMARY KEY,
"email" TEXT NOT NULL UNIQUE,
"first" TEXT NOT NULL,
"last" TEXT NOT NULL,
"verified_at" TIMESTAMP WITH TIME ZONE NOT NULL
);
CREATE INDEX email_idx ON "user" (email);
Support the Developer
Metadata
Release files for sql-artifex 0.62.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sql_artifex-0.62.0.tar.gz | 13.5 kB | Without provenance | Details for sql_artifex-0.62.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sql_artifex-0.62.0-py3-none-any.whl | Python 3 | none | any | Details for sql_artifex-0.62.0-py3-none-any.whl |
Total release size: 29.1 kB
Release files / sql_artifex-0.62.0.tar.gz
| Download URL | sql_artifex-0.62.0.tar.gz |
|---|---|
| Size | 13.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a72bec45cdf9e95f4b64322d58d1dd7374f57a471aad6de65eaa0e1fccf6d0e8
|
|
BLAKE2b-256 checksum How to use checksums |
64b9cba8645eb127fa7b07eaa71232d8b20ae1e516cbc460d7c5132fb23d7584
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"43","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / sql_artifex-0.62.0-py3-none-any.whl
| Download URL | sql_artifex-0.62.0-py3-none-any.whl |
|---|---|
| Size | 15.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5284378ac432d3c66522e7f072e55e866a06b8e644cf27870de74099ef33f17c
|
|
BLAKE2b-256 checksum How to use checksums |
a5a090d98b8d9ac67e7a7108453fc2b73615c4cb23ddab1673e82a874b5348c9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"43","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for sql-artifex 0.62.0
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.