Skip to main content

Database handling for fsspec filesystems

Project description

fsspec-db

Database tables and views as fsspec filesystems.

Build Status codecov License PyPI

Overview

fsspec-db exposes SQL databases through familiar fsspec operations:

  • ls("/") lists schemas.
  • ls("/main") lists tables and views.
  • info("/main/users/columns/id") returns column metadata.
  • cat_file("/main/users.parquet") materializes a table as bytes.
  • query("SELECT ...") returns a pyarrow.Table.
  • open("/main/users.arrow", "wb") or put_file(..., "/main/users.parquet") inserts rows.

Native backends are registered as db+sqlite, db+postgresql / db+postgres, and db+mysql.

[!WARNING] Database overwrite writes replace table contents. open(path, "wb"), pipe_file, and default put_file run truncate semantics before inserting incoming rows. Use "ab" or mode="append" to append instead.

Install

pip install fsspec-db

Quick Start

import fsspec
import pyarrow as pa
import pyarrow.ipc as ipc

fs = fsspec.filesystem("db+sqlite", database="app.db")

print(fs.ls("/", detail=False))
print(fs.ls("/main", detail=False))
print(fs.info("/main/users"))

table = fs.query("SELECT id, name FROM users WHERE id > ?", [0])

with fs.open("/main/users.arrow", "ab") as file:
    sink = pa.BufferOutputStream()
    with ipc.new_stream(sink, pa.table({"name": ["ada"]}).schema) as writer:
        writer.write_table(pa.table({"name": ["ada"]}))
    file.write(sink.getvalue().to_pybytes())

Path Shape

/main
/main/users
/main/users/columns/id
/main/users/indexes/idx_users_name
/main/users.arrow
/main/users.parquet
/main/active_users/definition.sql

Documentation

The full yardang/Sphinx docs cover concepts, path semantics, native SQL backends, Python-defined backends, and the API reference.

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

fsspec_db-0.2.0.tar.gz (120.3 kB view details)

Uploaded Source

Built Distributions

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

fsspec_db-0.2.0-cp310-abi3-win_amd64.whl (6.4 MB view details)

Uploaded CPython 3.10+Windows x86-64

fsspec_db-0.2.0-cp310-abi3-manylinux_2_28_x86_64.whl (7.3 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.28+ x86-64

fsspec_db-0.2.0-cp310-abi3-macosx_11_0_arm64.whl (6.2 MB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: fsspec_db-0.2.0.tar.gz
  • Upload date:
  • Size: 120.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for fsspec_db-0.2.0.tar.gz
Algorithm Hash digest
SHA256 717d2c4673e5e42a5be150cc75a3cf7ba9cd58b545f9c304136dc6c24070ec1c
MD5 b4c2e7d84859aa8e64d1af5a19d3eae5
BLAKE2b-256 13121fa98456bbe054edd7f412044720aa4f7bb308a713947b13b05e5195144e

See more details on using hashes here.

File details

Details for the file fsspec_db-0.2.0-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: fsspec_db-0.2.0-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 6.4 MB
  • Tags: CPython 3.10+, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for fsspec_db-0.2.0-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 ba3becca620b57f4a2b49c34e6c1a54faeb6d0af3ffd7ef5fe86234f31c91869
MD5 c655d73e1699fd57c31549a1d392ac00
BLAKE2b-256 c57f75fb46945f9b4d09c33a3a6fbbff15b1cd303c4d77dd711f8a8fb2c82b38

See more details on using hashes here.

File details

Details for the file fsspec_db-0.2.0-cp310-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for fsspec_db-0.2.0-cp310-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5d0b5649dc7c5bec7cbdf3bd0f127393c1ff710280c4a7d10583cd871fd4e5f3
MD5 6949127c670b0d30e5832df4104f735f
BLAKE2b-256 3ed1620901ca3769f41d54e19a7b8442e55fe43efa8423cce33b75ffdf317093

See more details on using hashes here.

File details

Details for the file fsspec_db-0.2.0-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for fsspec_db-0.2.0-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 140dc9e80b60f1381adfbdfd57be21b987428fc5b42519e151da258b033e62d4
MD5 bca54538668a14889a7a56a2ec0c432e
BLAKE2b-256 a0a1a5446ba969409b20b275c69ea75240d00ad35c6dc2458e5f705378fca50d

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