Lightweight online feature store backed by a SQL database (currently PostgreSQL) with a pandas API: automatic table creation, column migration, upserts, and chunked reads.
Project description
sql-feature-store
Lightweight online feature store backed by a SQL database, with a pandas API. Currently implemented for PostgreSQL; designed so other SQL backends (e.g. MySQL) can be added later.
What it does
- Parses a
DataFrameinto appropriate column types - Creates the destination table if it does not exist
- Migrates the table by adding new columns when the
DataFramehas extra ones - Supports write modes:
fail,replace,append - Supports index creation and
ON CONFLICT DO UPDATEupserts - Reads via SQL (optionally in chunks)
Install
pip install sql-feature-store
Requires Python >=3.10,<3.14.
Quickstart
import pandas as pd
from sql_feature_store import FeatureStore, PostgresConfig
config = PostgresConfig(
host="localhost",
port=5432,
user="postgres",
password="postgres",
dbname="postgres",
)
store = FeatureStore(config=config)
df = pd.DataFrame({"user_id": [1, 2, 3], "country": ["US", "UK", None]})
store.write("users", data_frame=df, write_option="replace")
result = store.read("select * from predictions.users")
# >>> result
# user_id country
# 0 1 US
# 1 2 UK
# 2 3 None
Credentials are passed in directly — sourcing them (env vars, AWS Secrets Manager, Vault, etc.) is the caller's responsibility.
Testing your own code
sql-feature-store ships a pytest plugin so your tests can hit a real
PostgreSQL without wiring up fixtures from scratch. Install the testing
extra:
pip install sql-feature-store[testing]
Three fixtures are auto-discovered:
sql_feature_store_postgres_proc— a Postgres process (spawned viapytest-postgresql, or an external DB whenSFS_POSTGRES_HOSTis set).sql_feature_store_config— aPostgresConfigwith a fresh randomwrite_schemaper test, dropped on teardown.sql_feature_store_fixture— a readyFeatureStorepointed at that schema.
import pandas as pd
def test_round_trip(sql_feature_store_fixture, sql_feature_store_config):
store = sql_feature_store_fixture
schema = sql_feature_store_config.write_schema
store.write("users", data_frame=pd.DataFrame({"user_id": [1, 2, 3]}))
result = store.read(f"select * from {schema}.users")
assert len(result) == 3
See docs/usage.md for the full
fixture reference and the external-database env vars.
Documentation
docs/usage.md— full API reference: chunked reads, write modes, indexes,ON CONFLICT DO UPDATEupserts, automatic column migration, and the pytest fixture reference.docs/roadmap.md— what's coming next, organised by target version (online feature store → multi-dialect → offline → 1.0).
Contributing
Bug reports, feature requests, and pull requests are welcome. See
CONTRIBUTING.md for development setup and the PR workflow,
and CHANGELOG.md for release notes.
Layout
sql-feature-store/
├── pyproject.toml
├── .pre-commit-config.yaml
├── docs/
│ ├── usage.md
│ └── roadmap.md
├── src/sql_feature_store/
│ ├── __init__.py
│ ├── config.py # PostgresConfig dataclass
│ ├── store.py # FeatureStore
│ └── testing/ # pytest plugin shipped as [testing] extra
│ └── plugin.py # fixtures: _postgres_proc, _config, _fixture
└── tests/
└── integration/ # one test file per feature area
License
Released under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sql_feature_store-0.2.0.tar.gz.
File metadata
- Download URL: sql_feature_store-0.2.0.tar.gz
- Upload date:
- Size: 9.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b1f8a102561431b9773c3f9134b7d4e870fd5c4b6788a673e1d9fc2c84a8b034
|
|
| MD5 |
23659861bd4bef4dfe4dc4c02aa1de9a
|
|
| BLAKE2b-256 |
91fd7fffbdfcc7cccef31ef8cf73aa8ae4d63ed32d4dad982c994aee51a4bbfe
|
Provenance
The following attestation bundles were made for sql_feature_store-0.2.0.tar.gz:
Publisher:
release.yml on mshka/sql-feature-store
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sql_feature_store-0.2.0.tar.gz -
Subject digest:
b1f8a102561431b9773c3f9134b7d4e870fd5c4b6788a673e1d9fc2c84a8b034 - Sigstore transparency entry: 1357148036
- Sigstore integration time:
-
Permalink:
mshka/sql-feature-store@18302b46f79a2ca2b686952ed239d180b0de7b89 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/mshka
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@18302b46f79a2ca2b686952ed239d180b0de7b89 -
Trigger Event:
push
-
Statement type:
File details
Details for the file sql_feature_store-0.2.0-py3-none-any.whl.
File metadata
- Download URL: sql_feature_store-0.2.0-py3-none-any.whl
- Upload date:
- Size: 11.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e3779cf744aea5f9a6ffa47dd1f8e1dba4c502d6d848b3cc846db3c251f01c52
|
|
| MD5 |
5a3b37ed5abe6cb4b1bd0406b70b1cc9
|
|
| BLAKE2b-256 |
727c30524eab63f3e8b8ba22307a3cfa778fedfb1c20add1bfd62833cc111af8
|
Provenance
The following attestation bundles were made for sql_feature_store-0.2.0-py3-none-any.whl:
Publisher:
release.yml on mshka/sql-feature-store
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sql_feature_store-0.2.0-py3-none-any.whl -
Subject digest:
e3779cf744aea5f9a6ffa47dd1f8e1dba4c502d6d848b3cc846db3c251f01c52 - Sigstore transparency entry: 1357148048
- Sigstore integration time:
-
Permalink:
mshka/sql-feature-store@18302b46f79a2ca2b686952ed239d180b0de7b89 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/mshka
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@18302b46f79a2ca2b686952ed239d180b0de7b89 -
Trigger Event:
push
-
Statement type: