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.2.0.tar.gz (4.9 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.2.0-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for flashsql-0.2.0.tar.gz
Algorithm Hash digest
SHA256 3ae136c6c3124cdc04ba3011554b54215b32a56391f7c21031c458fe77feaa76
MD5 0b20d6ecb86be6c6aebc3b4e7d28498d
BLAKE2b-256 93af1234a164b1e5056b17433053417c713cd2b2e4d8f53a2d8e4a08ce60b859

See more details on using hashes here.

File details

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

File metadata

  • Download URL: FlashSQL-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 5.4 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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1622b9b2150fad6f590795bb707f9e092bb27130da1a30909ea69ec424abc2bd
MD5 7e66c479f335ae4740cf39061c89bcd7
BLAKE2b-256 f639765c3bfada667bad25b54d52d1195552972fd879a6201a998c00eccfb387

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