Skip to main content

A lightweight key-value database using SQLite and APSW.

Project description

FlashSQL

FlashSQL is a lightweight key-value store built on top of SQLite. It is designed for simplicity and efficiency, providing a straightforward interface for storing, retrieving, and managing key-value pairs in an SQLite database.

Features

  • SQLite-based: Utilizes SQLite for persistent storage.
  • In-memory Option: Supports in-memory databases for transient data.
  • Efficient Storage: Optimized with PRAGMA settings for performance.
  • Flexible Key Management: Supports basic CRUD operations (Create, Read, Update, Delete) for keys.
  • Pattern Matching: Allows retrieval of keys based on patterns using SQL LIKE queries.
  • High Performance: Designed for high performance with optimized SQLite settings.
  • Fast Access Times: Provides quick access to stored values with efficient querying and indexing.

Installation

You can install FlashSQL using pip:

pip install FlashSQL

Usage

Initialization

To initialize a new instance of FlashSQL Client, provide the file path to the SQLite database. Use ":memory:" for an in-memory database.

from FlashSQL import Client

# For a file-based database
db = Client('database.db')

# For an in-memory database
db = Client(':memory:')

Storing Values

Use the set method to store a value under a specific key. If the key already exists, the value will be updated.

db.set('key', 'value')

Retrieving Values

Use the get method to retrieve the value associated with a key. If the key does not exist, None is returned.

value = db.get('key')
print(value)  # Output: 'value'

Deleting Values

Use the delete method to remove a key-value pair from the database.

db.delete('key')

Checking Key Existence

Use the exists method to check if a key is present in the database.

exists = db.exists('key')
print(exists)  # Output: False (if the key has been deleted)

Retrieving Keys

Use the keys method to retrieve a list of keys matching a specified pattern.

keys = db.keys('%')
print(keys) # Output: key

Closing the Database

Use the close method to close the database connection.

db.close()

Full Example

from FlashSQL import Client

# Initialize the database
db = from FlashSQL import Client
(':memory:')

# Store values
db.set('name', 'hexa')
db.set('age', 5)

# Retrieve values
print(db.get('name'))  # Output: 'hexa'
print(db.get('age'))   # Output: 5

# Check existence
print(db.exists('name'))  # Output: True
print(db.exists('address'))  # Output: False

# Retrieve keys with a pattern
print(db.keys('na%'))  # Output: ['name']

# Delete a key
db.delete('name')

# Close the database
db.close()

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contributing

Contributions are welcome! Please submit pull requests or open issues to improve the functionality and performance of FlashSQL.

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

flashsql-0.1.0.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

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

FlashSQL-0.1.0-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: flashsql-0.1.0.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.11.9

File hashes

Hashes for flashsql-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1e6dc2dfa442c9d6f64432258ffc5e039220cc5e24b0a075c20497ee7967c6ef
MD5 f70fd73df7e9b6bed07d695751db8059
BLAKE2b-256 9ef0ca51b2ce2e449870e019b518d945482ada68fba290de8939593a31c9fe28

See more details on using hashes here.

File details

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

File metadata

  • Download URL: FlashSQL-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.11.9

File hashes

Hashes for FlashSQL-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d13ac128b8f90f3e0b03a4c7f958c4173e18d93c84b44e21a56da87312602861
MD5 779984bed11ebeff2a12afe22ca448ba
BLAKE2b-256 9adc4979d673bfa1fdd4a16ae9fd6660e19f74d4cb774f96e7111e43cd168dcd

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