Skip to main content

Lightweight file-system database for Python projects.

Project description

pyfiles_db

Lightweight file-system database for Python projects

PRE RELISE FIRST VERSION OF PYFILES_D

About

pyfiles_db is a lightweight and fast library that allows using the file system as a database for Python projects. It is minimalistic, requires no full-fledged DBMS, and is ideal for small to medium projects where simplicity and speed are priorities, and when system resources are a concern. It is built on top of aiofiles which allows you to use the file system as a database without any server required. Also can with synchronous mode.

Features

  • Store data directly in folders and files (no server required)
  • Simple API — quick to start
  • Supports basic CRUD operations: Create, Read, Update, Delete
  • Minimal external dependencies
  • Designed for easy integration and flexibility

Installation

pip install python-files-db

Quick Start

from pyfiles_db import FilesDB

file_db = FilesDB()

db = file_db.init_sync()  # Or file_db.init_async() for async mode
# storage - path to database location, if is None use default path.

db.create_table(
    "users",
    columns={
        "id": "INT",
        "name": "TEXT",
        "age": "INT",
    },
    id_generator="id", # required unique value of table, if None use generator for auto increment.
)

db.new_data(table_name="users", data={
    "id": 1,
    "name": "Anton",
    "age": 17,
})

db.new_data(table_name="users", data={
    "id": 2,
    "name": "Alex",
    "age": 17,
})

user_id_1 = db.find("users", "id == 1")
# return [{"1": {"id": 1, "name": "Anton", "age": 17}}], 1 is file_id

user_id_2 = db.find("users", "id == 2") 
# return [{"2": {"id": 2, "name": "Alex", "age": 17}}], 2 is file_id

users_age_17 = db.find("users", "age == 17")
# return [
#     {"1": {"id": 1, "name": "Anton", "age": 17}}, # 1 is file_id
#     {"2": {"id": 2, "name": "Alex", "age": 17}, # 2 is file_id
# ]

Or async version:

from pyfiles_db import FilesDB
import asyncio
async def main():
    file_db = FilesDB()
    db = file_db.init_async("path/to/folder")
    await db.create_table(...)
    await db.new_data(...)
    res = await db.find(...)
asyncio.run(main())

Use Cases

  • Quick startups, prototypes, MVPs
  • Lightweight web applications, scripts, utilities
  • Projects not requiring a heavy DBMS
  • Personal projects and data analysis tools
  • low RAM and processor characteristics

Best Practices & Limitations

  • Not designed for high-load systems with thousands of requests per second
  • Maintain folder structure carefully to avoid naming collisions
  • As this uses the file system, consider transaction/concurrency limitations
  • Regularly back up the path folder

Contribution

Feedback, issues, and pull requests are welcome! Follow the contribution guidelines if available. Ensure your code is tested (tests in /tests/) and document changes.

License

This project is licensed under the Apache-2.0 License. See LICENSE for details.

Other

CODE_OF_CONDUCT

CONTRIBUTING

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

python_files_db-0.0.1a5.tar.gz (13.4 kB view details)

Uploaded Source

Built Distribution

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

python_files_db-0.0.1a5-py3-none-any.whl (24.4 kB view details)

Uploaded Python 3

File details

Details for the file python_files_db-0.0.1a5.tar.gz.

File metadata

  • Download URL: python_files_db-0.0.1a5.tar.gz
  • Upload date:
  • Size: 13.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for python_files_db-0.0.1a5.tar.gz
Algorithm Hash digest
SHA256 6dac53b1e8ff274de89a579d75b25357372849e5224aa38a6ab77e57b8f86da5
MD5 01fcfbf0d081c1b308718f6eae5b87f3
BLAKE2b-256 fd143886677406360b33035f1305d0506ca43aa2425451fb1361cdde6305315a

See more details on using hashes here.

File details

Details for the file python_files_db-0.0.1a5-py3-none-any.whl.

File metadata

File hashes

Hashes for python_files_db-0.0.1a5-py3-none-any.whl
Algorithm Hash digest
SHA256 4b977b2c52916113171c59cf362a46c9d2e7b53d986408c36cce70c687014569
MD5 cfdc77d6e0d9069ec775adce1b223ed5
BLAKE2b-256 7d9528d91f47111c3f9439db30c4813d9cb0bcf89f395df3866e207625f594a5

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