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.1.1.tar.gz (118.1 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.1-cp310-abi3-win_amd64.whl (6.3 MB view details)

Uploaded CPython 3.10+Windows x86-64

fsspec_db-0.1.1-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.1.1-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.1.1.tar.gz.

File metadata

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

File hashes

Hashes for fsspec_db-0.1.1.tar.gz
Algorithm Hash digest
SHA256 f48e54bd9ec7efba07b652ffcda4fb54feed79dd4441752f06eeef702ba20a5c
MD5 c7d4dcc1061186891ba634b804f1d555
BLAKE2b-256 323e6e04725fc23127c6a616bc4dd2f2ba78e8a268eee666df914e02b8cbb8b0

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for fsspec_db-0.1.1-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 28894576807bcf6aacf046b3ee4b44705b85fe5620c7bb1747e090c8528ee46d
MD5 dfe6d3298d0ba209dc5a7cde54fbe2ff
BLAKE2b-256 faef414e7c57bb32e2d3bf5adcdd2fb5271fa63dc7d471bbe942a8a4c8439ada

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for fsspec_db-0.1.1-cp310-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6e01748700ed264ba3f1a7a37179aef9f595cb34d6ecedc6eb719767071c22f3
MD5 4b0668e580128b4f218c4209becb166f
BLAKE2b-256 3b22052f28afd57aaf64593c6d8ff5539dfb09b7a6ac8bb2d7b77f2d9677b82b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for fsspec_db-0.1.1-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 94d6664b4c767b1b1e4632f976d2edb0eb1e1b6774f66f8c5703bd1b5c5ecb23
MD5 852c3c2f8f4ce74b5a0bc2f5451a1660
BLAKE2b-256 f4f92dcd5db7185f77351280b66beed8bb3d3e72b9ea6b34958dc2bfacab1976

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