Skip to main content

fakedb

fakedb oferece implementações assíncronas de bancos de dados fake inspirados em PostgreSQL e MongoDB, persistindo dados em sistemas de arquivos locais ou em backends compatíveis com Google Cloud Storage. Ele é útil para protótipos, testes e ambientes onde provisionar um banco real seria custoso ou demorado.

Recursos principais

  • FakePostgresDB: API parecida com SQLAlchemy/SQLModel, com suporte opcional a validação por Pydantic e materialização de resultados em modelos tipados.
  • FakeMongoDB: coleções estilo MongoDB com binding opcional a modelos Pydantic.
  • Backends plugáveis via StorageBackend, incluindo uma implementação local e uma variante para GCS.
  • Locking distribuído simples para coordenar operações concorrentes.

Instalação

pip install fakedb

Dependências opcionais:

pip install "fakedb[extras]"      # Pydantic, SQLModel, SQLAlchemy
pip install "fakedb[cloud]"       # google-cloud-storage

Exemplos rápidos

import asyncio
from fakedb import FakePostgresDB, LocalStorageBackend

async def demo():
    backend = LocalStorageBackend("/tmp/fake-db")
    db = FakePostgresDB(backend, "analytics")
    await db.create_table("users", {"id": "int", "name": "str"})
    await db.insert("users", [{"id": 1, "name": "Alice"}])
    rows = await db.query("users")
    print(rows)

asyncio.run(demo())

Desenvolvimento

make test          # executa a suíte com pytest
make coverage      # relatórios de cobertura

Sinta-se à vontade para abrir issues e PRs com melhorias.

Metadata

Release files for fakedb 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fakedb 0.1.0
File Size Uploaded
fakedb-0.1.0.tar.gz 21.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for fakedb 0.1.0
File Interpreter ABI Platform
fakedb-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 47.4 kB

Release files / fakedb-0.1.0.tar.gz

Download URL fakedb-0.1.0.tar.gz
Size 21.2 kB
Tags Source
SHA-256 checksum
How to use checksums
4c6fb855467006e769ecb9f2c5aad4bded51eb0099b4efb4b4aacbd48c3e7152
BLAKE2b-256 checksum
How to use checksums
770f510a6c89841c2d4c63e121306a2894452c47d2de57a1a181d78f1a548dde
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

Release files / fakedb-0.1.0-py3-none-any.whl

Download URL fakedb-0.1.0-py3-none-any.whl
Size 26.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
35ecd65431877afe5b9c128e3416613431e5ea97456ea24df29c48e965fd8c9e
BLAKE2b-256 checksum
How to use checksums
0ffd92f857000094098c11673515490ad49964b3a1720dc5b415eb2daf5a0785
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page