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.

SQLite is the first native backend and is registered as db+sqlite.

[!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, SQLite reads and writes, 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.1.0.tar.gz (81.5 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.1.0-cp310-abi3-win_amd64.whl (4.1 MB view details)

Uploaded CPython 3.10+Windows x86-64

fsspec_db-0.1.0-cp310-abi3-manylinux_2_28_x86_64.whl (4.9 MB view details)

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

fsspec_db-0.1.0-cp310-abi3-macosx_11_0_arm64.whl (4.1 MB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: fsspec_db-0.1.0.tar.gz
  • Upload date:
  • Size: 81.5 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.1.0.tar.gz
Algorithm Hash digest
SHA256 932c423383d6f656ec5618b4929ec6dcccdca9c3eba91662af2a3d21a4aea62a
MD5 0fde5f69b1ec839482689c22a98b12f1
BLAKE2b-256 25d89a8491811399a57260bd41fea2dde36b06130aadccf55c03efe20812c9f2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fsspec_db-0.1.0-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 4.1 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.1.0-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 2f8d1e54cf6198b849eb0639adcc5391caae13fbe3951bbb6fdfcd85f522c20f
MD5 29f58a864dd64422e856b374179ce378
BLAKE2b-256 d37e6427b73099b89b51216acb4eaf2038eeb44b60071aef0585832c1ecb231e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for fsspec_db-0.1.0-cp310-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ac74ab2815d913b039d0f8522f7c52f2845efee557869f4198f969424fc17fbc
MD5 4a844d2e3ec33e274103a87f324e2b97
BLAKE2b-256 c6afaa78d0207665bc52cebf58aed632e72c77ac0b7936b4c5e45bb5d77eac91

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for fsspec_db-0.1.0-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e40da359abb2b2d407eebaac8ae5691ecb8eb705b630c54d1a7a6bb08fa14e8d
MD5 342dad2d551a8f603ea240600451c26f
BLAKE2b-256 3e8495b2d3d1de944f7d079cc8da821c98c501b0754a45fe3d0a1d477ce351c2

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