Overview
Sqlitis is a tool to convert plain SQL queries to SQLAlchemy expressions. It is usable from the command line or as a library.
Sqlitis converts to the SQLAlchemy expression language. It does not support the SQLAlchemy ORM.
$ pip install sqlitis
Examples
Turning a select query into a sqlachemy expression:
$ sqlitis 'select foo.name, bar.value from foo join bar'
select([foo.c.name, bar.c.value]).select_from(foo.join(bar))
Converting a join:
$ sqlitis 'foo join bar on foo.id = bar.foo_id and (foo.val < 100 or bar.val < 100)'
foo.join(bar, and_(foo.c.id == bar.c.foo_id, or_(foo.c.val < 100, bar.c.val < 100)))
Running tests
Use tox to run the tests.
$ pip install tox
### Run everything
$ tox
### Run the unit/functional tests
$ tox -e py36
### Run style checks
$ tox -e flake8 black
The code is formatted using black.
### Reformat the code with black
$ make format
### Check if black needs to be run. This does not reformat.
$ tox -e black
There are three types of tests:
- Unit tests of the internal model classes
- Unit tests of the core
to_sqlafunction - Functional tests that execute the generated SQLAlchemy expressions against a sqlite database
- Functional tests of the CLI
These tests are parameterized (data driven) using data from test/*.yaml
SQL Support Checklist
-
Select
-
Star:
SELECT * FROM foo -
Multiple columns:
SELECT a, b, c FROM foo -
Qualified column names:
SELECT foo.a, foo.b FROM foo -
Column aliases:
SELECT foo.id AS foo_id, foo.name AS foo_name from FOO -
Joins
-
Inner Join:
SELECT * FROM foo JOIN barSELECT * FROM foo INNER JOIN bar
-
Cross Joins
SELECT * FROM foo, barSELECT * FROM foo CROSS JOIN bar
-
Left/Right Joins
-
Outer Joins
-
-
On Clauses:
SELECT foo.a, bar.b FROM foo JOIN bar ON foo.id = bar.foo_id -
Conjuctions (AND/OR):
SELECT foo.a, bar.b FROM foo join bar ON foo.id = bar.foo_id AND foo.val > 1 -
Select from subquery:
SELECT id FROM (SELECT * FROM foo) -
Where:
SELECT id FROM foo WHERE id = 123 -
Between:
SELECT a FROM foo WHERE foo.val BETWEEN 1 AND 20 -
Select distinct:
SELECT DISTINCT a FROM foo -
Aggregate functions (SUM, AVG, COUNT, MIN, MAX):
SELECT COUNT(*) FROM foo -
Group by:
SELECT COUNT(*) FROM foo GROUP BY column -
Like
-
Limit/offset
-
Order by
-
-
Insert
-
Update
-
Delete
Metadata
Release files for sqlitis 0.0.5
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 | |
|---|---|---|---|---|
| sqlitis-0.0.5.tar.gz | 9.7 kB | Without provenance | Details |
Release files / sqlitis-0.0.5.tar.gz
| Download URL | sqlitis-0.0.5.tar.gz |
|---|---|
| Size | 9.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4fcd04a027c9670a8bbbbd66b4d5d3db1baaa4f1b40fa96c4de90309113cfaf0
|
|
BLAKE2b-256 checksum How to use checksums |
26c2b78e97be6702abd148c05fc61b329f82a07aa34f24cd1b57f7a268626c37
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.6.3
|
Security for sqlitis 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.