Skip to main content

A simple, clean SQLite database wrapper for Python

Project description

⚡ sqliter

A simple, clean, and ridiculously fast SQLite database wrapper for Python. Zero dependencies. No boilerplate. Just queries.

Stop writing the same database setup code over and over. sqliter abstracts away connections, cursors, and commits so you can focus on your application logic.

🚀 The Difference: Why use sqliter?

Working with standard sqlite3 requires a lot of repetitive typing. sqliter fixes that.

❌ The Old Way (Standard sqlite3)

import sqlite3

# 1. Open connection
# 2. Create cursor
# 3. Execute query
# 4. Remember to commit!
# 5. Remember to close!
conn = sqlite3.connect('myapp.db')
cursor = conn.cursor()
cursor.execute("INSERT INTO users (name, age) VALUES (?, ?)", ("Elone", 21))
conn.commit()
conn.close()

✅ The Clean Way (Using sqliter)

from sqliter import Database

db = Database("myapp.db")

# Automatically connects, executes, commits, and closes securely behind the scenes.
db.query("INSERT INTO users (name, age) VALUES (?, ?)", ("Elone", 21))

✨ Features at a Glance

  • Zero dependencies — Built entirely on Python's native sqlite3. No bulky external packages.
  • No repetitive boilerplate — You never have to type sqlite3.connect() or conn.cursor() again.
  • One method for all operations — A simple and predictable db.query() API for everything.
  • Dict-like rows by default — Fetches results as dictionaries out of the box, making your data instantly accessible.
  • Proper exceptions — Strict error handling ensures database failures never go unnoticed.
  • Built for "Us," not Enterprise — This package was created for our own personal projects to solve real annoyances, not to be a bloated corporate framework. It's lightweight, easy to understand, and belongs to the community.

📦 Installation

Install the package via PyPI using the distribution name sqliter-lochan:

pip install sqliter-lochan

(Note: You will import it in your code simply as sqliter)


💻 Quick Start

from sqliter import Database

# Initialize database (creates the file if it doesn't exist)
db = Database("myapp.db")

# Create a table
db.query("CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY, name TEXT, age INTEGER)")

# Insert data (Default operation is 'commit')
db.query("INSERT INTO users (name, age) VALUES (?, ?)", ("Elone", 21))

# Fetch a single row
user = db.query("SELECT * FROM users WHERE name = ?", ("Elone",), operation="fetchone")
print(dict(user))  
# Output: {'id': 1, 'name': 'Elone', 'age': 21}

# Fetch multiple rows
users = db.query("SELECT * FROM users", operation="fetchall")
for u in users:
    print(dict(u))

🛠 Operations Reference

The operation parameter in db.query() determines what you get back.

operation= Use Case Returns
"commit" (Default) INSERT, UPDATE, DELETE, CREATE True on success
"fetchone" SELECT a single row Row object (dict-like) or None
"fetchall" SELECT multiple rows list[Row]

🛡️ Error Handling

sqliter comes with custom exceptions so you can catch database failures predictably without crashing your main application.

from sqliter import Database, DatabaseError

db = Database("myapp.db")

try:
    # Attempting an operation with a typo in the table name
    db.query("INSERT INTO bad_table (name) VALUES (?, ?)", ("Elone", 21))
except DatabaseError as e:
    print(f"Database operation failed: {e}")

🤝 Contributing

Because this is a personal-use tool and not a massive enterprise project, the codebase is incredibly easy to jump into. We actively welcome contributions!

If you want to add a feature, fix a bug, or just make the code cleaner for everyone, feel free to submit a pull request. This is our tool now.

Running Tests locally:

pip install pytest
pytest tests/

📄 License

MIT License

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

sqliter_lochan-0.1.3.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

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

sqliter_lochan-0.1.3-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file sqliter_lochan-0.1.3.tar.gz.

File metadata

  • Download URL: sqliter_lochan-0.1.3.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for sqliter_lochan-0.1.3.tar.gz
Algorithm Hash digest
SHA256 e5187dfea9ffc2154bbfc062c1dbc017225ca72e7406da826a58bfc999a12e2b
MD5 44ade2f227e8b791c114b135d7d18bf8
BLAKE2b-256 dac1a5d7eab207364b751023eeea6e40c285035845538772fd3d755986f8bca2

See more details on using hashes here.

File details

Details for the file sqliter_lochan-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: sqliter_lochan-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 4.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for sqliter_lochan-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 6f20f745ba264cd9c5a840d42550e0c6f77040594b83d179f8168bd87cb6778d
MD5 85a1b76fbd9bd903f16e15a34ee80040
BLAKE2b-256 652c6d6314eb60bdc2683914d267164104d0d28e9874b2fc096b6e71f316c334

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