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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

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

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for python_files_db-0.0.1a4-py3-none-any.whl
Algorithm Hash digest
SHA256 dd22d03e24e0e4bd1418aaa3f6e7f5b08453e3ddd5522045d8ea3974bb1a93a8
MD5 0c47b42ccb1781409db7b3caa77364b5
BLAKE2b-256 c8f05b7ba379a3f8a4b0dddd22a7a9e9a0af7aee43a795e31b275676e27891bc

See more details on using hashes here.

Provenance

The following attestation bundles were made for python_files_db-0.0.1a4-py3-none-any.whl:

Publisher: publish.yml on LangNeuron/pyfiles_db

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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