Skip to main content

Simple local file storage backed by SQLite with optional AES-GCM encryption

Project description

Q1: Simple Local File Storage

A production-grade, pip-installable Python package that offers simple local file storage backed by SQLite and optional AES-GCM encryption.

Features

  • Store and retrieve files with a simple API
  • Transactional operations with ACID guarantees
  • Optional at-rest AES-256-GCM encryption
  • Integrity verification with SHA-256
  • File deduplication
  • Soft and hard delete with recovery options
  • Concurrency support with SQLite WAL mode

Installation

pip install q1

For encryption support:

pip install q1[crypto]

Quick Start

from q1 import Q1

# Create or open a storage location
with Q1("./my_store") as store:
    # Store a file
    file_id = store.put("example.txt", b"Hello, world!")
    
    # Retrieve the file
    content = store.get(file_id)
    
    # Get file information
    info = store.info(file_id)
    print(f"File name: {info.name}, size: {info.size} bytes")
    
    # List all files
    for file_info in store.list():
        print(f"ID: {file_info.id}, Name: {file_info.name}")
    
    # Delete a file (soft delete by default)
    store.delete(file_id)
    
    # Undelete a file
    store.undelete(file_id)
    
    # Permanently delete
    store.delete(file_id, hard=True)

Using Encryption

from q1 import Q1
from q1.crypto import AesGcmCrypto

# Create an encryption provider with a secure key
crypto = AesGcmCrypto(key=b"a" * 32)  # Use a proper secure key in production!

# Open storage with encryption
with Q1("./encrypted_store", crypto_provider=crypto) as store:
    # All operations work the same as before, but data is encrypted at rest
    file_id = store.put("secret.txt", b"Confidential information")
    content = store.get(file_id)  # Automatically decrypted

Development

Setting up the development environment

# Clone the repository
git clone https://github.com/yourusername/q1.git
cd q1

# Create a virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install in development mode
pip install -e ".[dev,crypto]"

Running tests

pytest

Type checking

mypy --strict q1

Building the package

flit build

Continuous Integration

This project uses GitHub Actions for continuous integration, running tests on:

  • Python 3.9, 3.10, 3.11, and 3.12
  • Windows, macOS, and Linux

The CI pipeline performs:

  1. Test execution with coverage reporting
  2. Type checking with mypy
  3. Package building
  4. Optional PyPI deployment for tagged releases

License

MIT License - See LICENSE file for details.

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

q1_storage-0.1.0.tar.gz (42.9 kB view details)

Uploaded Source

Built Distribution

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

q1_storage-0.1.0-py3-none-any.whl (39.6 kB view details)

Uploaded Python 3

File details

Details for the file q1_storage-0.1.0.tar.gz.

File metadata

  • Download URL: q1_storage-0.1.0.tar.gz
  • Upload date:
  • Size: 42.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.12

File hashes

Hashes for q1_storage-0.1.0.tar.gz
Algorithm Hash digest
SHA256 40cfd68c718438f9d19d6d903e5a52b22a50b370051decec02aea55db87079b4
MD5 2051ba40fda568feb3871d183a65a9ec
BLAKE2b-256 4923fb3895a11b1c6c12f6a2867f40440f8f78b987fbf442f805eb39e7d40038

See more details on using hashes here.

File details

Details for the file q1_storage-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: q1_storage-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 39.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.12

File hashes

Hashes for q1_storage-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7b5965022d6793e0a6946122f309fc98427dc22a2135e52e0cd01c9423796c5a
MD5 32e05f1173b356555aabe471fab3d2c8
BLAKE2b-256 dc99e1f2303e1358873b7fc07585fecc1b40ee22f97bc89621858afc3ffc7661

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