Skip to main content

No project description provided

Project description

nanoSQLite

nanoSQLite is a lightweight Python wrapper for SQLite. With around 200 lines of Python code, it provides an uncomplicated interface for managing SQLite databases.

Despite its simplicity, nanoSQLite offers a robust set of functionalities that enable you to interact with SQLite databases seamlessly, without having to worry about managing cursors and connections manually.

It's designed to make working with SQLite in Python as straightforward and Pythonic as possible.

Features

  • Easy Setup: Create connections to SQLite databases with a single function call.
  • Intuitive Interface: Insert, update, and delete data using a simple syntax.
  • Quick Prototyping: Manage data efficiently with a few lines of code, perfect for rapid prototyping and basic projects.
  • Flexible: Execute custom SQL statements using the underlying sqlite3.Cursor and sqlite3.Connection objects.
  • Robust: The sqlite3 module is part of the Python standard library and has been extensively tested.
  • Pythonic: The nanoSQLite API is designed to be as Pythonic as possible, which makes it intuitive and easy to use.
  • Pure Python: nanoSQLite is written with no dependencies.
  • Lightweight: nanoSQLite is a single-file module with around 200 lines of code.
  • Open Source: nanoSQLite is distributed under the MIT license.

Examples

Most of database operations can be covered with the following examples:

  1. Create a new SQLite database with a table:

    from nanoSQLite import NanoSQLite
    
    db = NanoSQLite("people")
    db.create_table(
        "friends",
        {
            "id": "INTEGER PRIMARY KEY AUTOINCREMENT",
            "name": "TEXT",
            "age": "INTEGER",
            "height": "REAL",
            "is_cool": "BOOLEAN",
        },
    )
    
  2. Insert data:

    db.insert("friends", {"name": "John", "age": 20, "height": 1.8, "is_cool": True})
    db.insert("friends", {"name": "Jane", "height": 1.7, "is_cool": False})
    db.insert("friends", {"name": "Bob"})
    
  3. Update data:

    db.update("friends", {"age": 21, "height": 1.9}, {"name": "John"})
    db.update("friends", {"age": 5}, {"name": "Bob"})
    
  4. Delete data:

    db.delete("friends", {"name": "Jane"})
    
  5. Select data:

    db.select("friends", ["name", "age", "height", "is_cool"], {"name": "Bob"})
    db.select_first("friends", ["name", "age", "height", "is_cool"], {"name": "Bob"})
    db.select_all("friends")
    

When more advanced functionality is required, you can still execute custom SQL statements, using the underlying sqlite3.Cursor and sqlite3.Connection objects:

data = [
    ("Monty Python Live at the Hollywood Bowl", 1982, 7.9),
    ("Monty Python's The Meaning of Life", 1983, 7.5),
    ("Monty Python's Life of Brian", 1979, 8.0),
]
db.cursor.executemany("INSERT INTO movie VALUES(?, ?, ?)", data)
db.connection.commit()

Installation

You can install nanoSQLite from PyPI:

pip install nanoSQLite

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

nanoSQLite-1.0.0.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

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

nanoSQLite-1.0.0-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file nanoSQLite-1.0.0.tar.gz.

File metadata

  • Download URL: nanoSQLite-1.0.0.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for nanoSQLite-1.0.0.tar.gz
Algorithm Hash digest
SHA256 fbaf46e33dd3f2a44a3c39be684e131ec8056d8825006b79541a69e206e077d0
MD5 8dd90b33fc1584debfe55dda626c8693
BLAKE2b-256 324515989f826de26d86c4369036485821e652b9bf76f2a11b044b3dd4d1790f

See more details on using hashes here.

File details

Details for the file nanoSQLite-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: nanoSQLite-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for nanoSQLite-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ac326eb49a1f5ed9842fe70334b46bd89619f44a111a5fd46e7a296c8a1522fa
MD5 583bd4a3faf1c0559442839e4b104840
BLAKE2b-256 eaed3695d0b7dc36594f0d3c1191207b2b6a6c83a4b96c5f1e5431c421d4d396

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