Skip to main content

SQLLEX alpha v0.1.5 📚

Python:3.9 Language grade: Python Total alerts


Better than sqlite3. Seriously, try it out

Installation

pip install sqllex

About

Use databases without thinking about SQL. Let me show you how sqllex makes your life easier. Imagine you need create some database, save some data into it and take it back. That's how your code will look like.

from sqllex import *

# Create some database, with simple structure
db = SQLite3x(
    path='my_data.db',
    template= {
        "users": {
            "username": [TEXT, NOT_NULL],
            "age": INTEGER,
        }
    }
)

# Insert some data
db.insert('users', ['Sqllex', 33])

# Take it back
users = db.select('username', from_table='users', where={'age': 33})

print(users)  # [('Squllex',)]

Ok, what if you need more complex structure with FOREIGN KEYs? Not a big deal.

from sqllex import *

DB_TEMPLATE = {
    "groups": {
        "group_id": [INTEGER, PRIMARY_KEY, UNIQUE],
        "name": [TEXT, NOT_NULL, DEFAULT, 'Unknown'],
    },

    "users": {
        "username": [TEXT, NOT_NULL],
        "group_id": INTEGER,

        FOREIGN_KEY: {
            "group_id": ["groups", "group_id"]
        },
    }
}

# and do your business ...

What if I have LARGE dataset to insert? Still easy.

...
# Your awesome dataset
dataset = [
    [3, "pi", 0],
    [1, "pi", 1],
    [4, "pi", 2],
    [1, "pi", 3],
    [5, "pi", 4],
    [9, "pi", 5],
    [2, "pi", 6],
    ...
]

# One line
db.insertmany('math', dataset)

# Done

Advances

Ok ok, what if you are SUPER_PRO_1337_SQL_GOY, and you need 100% of SQL features. Check this out.

from sqllex import *

db = SQLite3x(
    path='./path/my_awesome.db',
    template={
        "groups": {
            "group_id": [INTEGER, PRIMARY_KEY, UNIQUE],
            "name": [TEXT, NOT_NULL, DEFAULT, 'Unknown'],
        }
    }
)

# Insert some groups into groups table
db.insertmany(
    'groups',
    group_id=[1, 2],
    name=["Admin", "User"],
)


# Let's create a new table with some FOREIGN_KEYs
db.create_table(
    name='users',
    columns={
        "username": [TEXT, NOT_NULL, DEFAULT, 'Unknown'],
        "group_id": INTEGER,
        FOREIGN_KEY: {
            "group_id": ["groups", "group_id"]
        },
    },
    without_rowid=True,
    as_=__something__
)

# Insert some users into users table
db.insertmany(
    table='users',
    username=['User_1', 'User_2', 'User_3', 'User_4', 'User_5', 'User_6'],
    group_id=[1, 2, 1, 1, 2, 2]
)

db.insert(
    or_=REPLACE,
    table='users',
    username='User_4',
    group_id=1,
)

# ANd now take it back whith some conditions
users = db.select(
    select='username',
    table='users',
    where={
        'group_id': 2
    },
    order_by={
        'username': 'DESC'
    },
    with_=__something__,
    limit=10,
    offset=1,
    execute=True,
)

# and do your business ...

Not enough? Need examples? Read more in Sqllex Wiki! (link)


Other

TODO-list

Metadata

Release files for sqllex 0.1.5.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sqllex 0.1.5.1
File Size Uploaded
sqllex-0.1.5.1.tar.gz 13.2 kB Details

Release files / sqllex-0.1.5.1.tar.gz

Download URL sqllex-0.1.5.1.tar.gz
Size 13.2 kB
Tags Source
SHA-256 checksum
How to use checksums
d717df13e179e1976d73b7b7ae4b3ef05d85db4f028c2db93387c49c17b0a5f1
BLAKE2b-256 checksum
How to use checksums
4ea89609d81b3c12e75a34a562c92111e64cdf341b81834be6e896b80bb43728
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

Release history Release notifications | RSS feed

0.3.0

2 release files

0.2.3

2 release files

0.2.0.0

1 release file

0.1.8.8

1 release file

0.1.8.7

1 release file

0.1.8.6

1 release file

0.1.8.5

1 release file

0.1.8.4

1 release file

0.1.8.3

1 release file

0.1.8.2

1 release file

0.1.7.2

1 release file

0.1.7.1

1 release file

0.1.7

1 release file

0.1.6.5

1 release file

0.1.6.3

1 release file

0.1.6.2

1 release file

0.1.6.1

1 release file

0.1.5.2

1 release file

This release

0.1.5.1 This release

1 release file

0.1.5

1 release file

0.1.3

1 release file

0.1.2

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page