Universal SQL Builder
SQL framework ORM independent, it helps you build sql query in python
What ever you using Hive, HBase, Spark* SQL, Django & FLASK etc so you can gernate simple SQL query
Its return raw sql query string this can be use in any Framework
Installation
Step 1: pip install universal-sql-builderStep 2:
from UniversalSqlBuilder import UniversalSqlBuilderStep 3: Flow the examples....
Select
UniversalSqlBuilder.table("employee").select("id,name").select(",department").get()
Where
You can use key and value based parameters : where("city=", "ABC")Or you can use raw where query : where("col=(select id from users)")
UniversalSqlBuilder.table("employee").select("id,name").select(",department").where("ram=(select id from users)").where("city=", "delhi").get()
OrWhere and WhereBetween
If you want data according min and max use :
whereBetween("age",[200,300])
UniversalSqlBuilder.table("employee").select("id,name").whereBetween("age",[200,300]).get()
Using OR with where :
UniversalSqlBuilder.table("employee").select("id,name").orWhere("seller=",'100').get()
GroupBy, OrderBy amd Limit
Use of group by : groupBy("name")UniversalSqlBuilder.table("employee").select("id,name").groupBy("name").get()
Use order by : orderBy("ID","desc")
UniversalSqlBuilder.table("employee").select("id,name").orderBy("ID","desc").get()
use with limit : limit(10,20)
UniversalSqlBuilder.table("employee").select("id,name").limit(10,20).get()
Join ('FULL OUTER', 'INNER', 'LEFT', 'RIGHT', 'JOIN')
Default :
join("users","users.id=employee.emp_id")FULL OUTER : join("users","users.id=employee.emp_id","FULL OUTER")
INNER : join("users","users.id=employee.emp_id","INNER")
LEFT : join("users","users.id=employee.emp_id","LEFT")
RIGHT : join("users","users.id=employee.emp_id","RIGHT")
JOIN : join("users","users.id=employee.emp_id","JOIN")
Having & OrHaving
Using OR with Having :
UniversalSqlBuilder.table("employee").select("id,name").orHaving("seller=",'100').get()
You can use key and value based parameters : having("city=", "ABC")
Or you can use raw where query : having("col=(select id from users)")
UniversalSqlBuilder.table("employee").select("id,name").select(",department").having("id=(select id from users)").having("city=", "delhi").get()
Making Advance Query
Using OR with Having :
print(UniversalSqlBuilder.table("employee")
.select("id,name")
.select(",department")
.where("city=", "delhi")
.where("order_id=("+UniversalSqlBuilder.table("orders as temp").select("temp.id").orderBy("temp.id", "desc").get()+")")
.orWhere("seller=", '100')
.orWhere("brand=", 'rock')
.having("city=", "delhi")
.orHaving("seller=", '100')
.orHaving("brand=", 'rock')
.whereBetween("age", [200, 300])
.join("users", "users.id=employee.emp_id", "left")
.join("cars", "cars.id=employee.emp_id")
.groupBy("name")
.orderBy("ID", "desc")
.limit(10, 20).get())
SELECT id, name, department FROM employee LEFT JOIN users ON users.id = employee.emp_id INNER JOIN cars ON cars.id = employee.emp_id WHERE city = 'delhi' AND order_id = (SELECT temp.id FROM orders AS temp ORDER BY temp.id DESC) AND age >= 200 AND age <= 300 AND (seller = '100' OR brand = 'rock') GROUP BY name HAVING city = 'delhi' AND (seller = '100' OR brand = 'rock') ORDER BY ID DESC LIMIT 20 , 10
Metadata
Release files for universal-sql-builder 0.1.1
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 |
|---|---|---|---|---|
| universal-sql-builder-0.1.1.tar.gz | 8.0 kB | Without provenance | Details for universal-sql-builder-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| universal_sql_builder-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for universal_sql_builder-0.1.1-py3-none-any.whl |
Total release size: 16.2 kB
Release files / universal-sql-builder-0.1.1.tar.gz
| Download URL | universal-sql-builder-0.1.1.tar.gz |
|---|---|
| Size | 8.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e254d96b296fdbc2f0741b2e49532237d78ef9b430c2791adf76a23942755f0a
|
|
BLAKE2b-256 checksum How to use checksums |
08dcb5aa6e45fe106e7b66ef5cad115b8b644fb927335a5254a34bd08cf601ad
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5
|
Release files / universal_sql_builder-0.1.1-py3-none-any.whl
| Download URL | universal_sql_builder-0.1.1-py3-none-any.whl |
|---|---|
| Size | 8.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
85def83a64c0af5d52f2bd15237dd2c8ec4f2f40b445bc9796086d2da0c40624
|
|
BLAKE2b-256 checksum How to use checksums |
e20a7ccba77064ad6f362406547e87d439bc5050a52144e9d44dcf66e60dee7e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5
|
Security for universal-sql-builder 0.1.1
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.