Skip to main content

Thin wrapper on top of SQL that enables you write SQL code in python easily

Project description

Supersql Library

Supersql is a very thin wrapper on top of SQL that enables you write SQL code in python easily.

 

Why?

Let's be honest, writing sql templates using string formatting is really painful. SQLAlchemy is great, but sometimes an ORM is not what you need, and whilst the new f strings in python solve a lot of problems, complex SQL templating is not of them.

Supersql makes it super simple to connect to and start querying a database in python.

Let the code do the explanation:

from supersql import Connection, Query


connection = Connection('postgres:localhost:5432', user='postgres', password='postgres')

query = Query()


results = query.SELECT(
        'first_name', 'last_name', 'email'
    ).FROM(
        'employees'
    ).WHERE('email', equals='someone@example.com').run()


for result in results:
    print(result)

 

Too many magic literals? I agree. Let's try that again with a Schema

# Schemas help you remove all those magic literals e.g. 'email' string typed twice
# from your code
from supersql import Schema, String, Date, Integer

class Employee(Schema):
    __pk__ = ('email', 'identifier')

    identifier = UUID(pg='uuid_version1', mysql=None)  # mysql included for examples sake
    email = String(required=True, unique=None, length=25)
    age = Integer()
    first_name = String(required=True)
    last_name = String(25)
    created_on = Date()


# Now lets try again
emp = Employee()
results = query.SELECT(
    emp.first_name, emp.last_name, emp.email
).FROM(
    emp
).WHERE(
    emp.email, equals='someone@example.com'
).run()

 

NOTE: Still Very Much In Development -- Expected Launch Date (November 11 2019)

Supersql is not installable until launch

Project details


Download files

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

Source Distribution

supersql-2019.0.4.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

supersql-2019.0.4-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file supersql-2019.0.4.tar.gz.

File metadata

  • Download URL: supersql-2019.0.4.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/0.12.17 CPython/3.7.4 Darwin/18.7.0

File hashes

Hashes for supersql-2019.0.4.tar.gz
Algorithm Hash digest
SHA256 fc2c9a45a785061869eff2353f00740169f806e89a618cae6568c63010dac38f
MD5 4bf8296b2621e5de15f30c462b7d8478
BLAKE2b-256 6cecafd94c2c47420e3134a78841dfbd9aef816a04f8ee6779cb308c122472e4

See more details on using hashes here.

File details

Details for the file supersql-2019.0.4-py3-none-any.whl.

File metadata

  • Download URL: supersql-2019.0.4-py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/0.12.17 CPython/3.7.4 Darwin/18.7.0

File hashes

Hashes for supersql-2019.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 88b68fee41bbaed3d43ea747fcb007c1032c70d573657fc99b5a5dcb18d00b06
MD5 483d0f959c66f633f4a74453f825ddfe
BLAKE2b-256 23c53ba1fa54f816d2a4f2d234fadfa773ae8552621ef2b08cc2cc5fb1981864

See more details on using hashes here.

Supported by

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