Store#
- featherstore.store.create_store(store_name, *, warnings='warn')[source]#
Creates a new store.
If a store with that name already exists, a warning is issued unless
warnings='ignore', and the existing store is returned. This method does not raiseStoreAlreadyExistsError.- Parameters:
- Returns:
The new or existing store.
- Return type:
- Raises:
NotConnectedError – If FeatherStore is not connected to a database.
ForbiddenStoreNameError – If
store_nameis reserved or not a valid path name.TypeError – If
store_nameis not a str.ValueError – If
warningsis not'warn'or'ignore'.
- featherstore.store.rename_store(store_name, *, to)[source]#
Renames a store.
- Parameters:
- Raises:
NotConnectedError – If FeatherStore is not connected to a database.
StoreNotFoundError – If the store does not exist.
StoreAlreadyExistsError – If the new store name already exists.
ForbiddenStoreNameError – If the new store name is reserved or not a valid path name.
TypeError – If
store_nameortois not a str.
- featherstore.store.drop_store(store_name, *, warnings='warn')[source]#
Deletes a store.
Warning: You cannot delete a store containing tables. All tables must be deleted first.
- Parameters:
- Raises:
NotConnectedError – If FeatherStore is not connected to a database.
StoreNotEmptyError – If the store still contains tables.
ForbiddenStoreNameError – If
store_nameis reserved or not a valid path name.TypeError – If
store_nameis not a str.ValueError – If
warningsis not'warn'or'ignore'.
- featherstore.store.list_stores(*, like=None)[source]#
Lists stores in the database.
- Parameters:
like (str, optional) – Filters store names with SQL wildcards.
?matches one character and%matches any number of characters. Matching is case-insensitive. Default isNone.- Returns:
A list of the stores in the database.
- Return type:
- Raises:
NotConnectedError – If FeatherStore is not connected to a database.
TypeError – If
likeis not a str orNone.
- featherstore.store.store_exists(store_name)[source]#
Returns whether a store exists in the current database.
- Parameters:
store_name (str) – The name of the store.
- Return type:
- Raises:
NotConnectedError – If FeatherStore is not connected to a database.
ForbiddenStoreNameError – If
store_nameis reserved or not a valid path name.TypeError – If
store_nameis not a str.
- class featherstore.store.Store(store_name)[source]#
Bases:
objectProvides common table operations within a store.
Stores are directories for organizing data in logical groups within your FeatherStore database.
Selects an existing store.
- Parameters:
store_name (str) – The name of the store to be selected.
- Raises:
NotConnectedError – If FeatherStore is not connected to a database.
StoreNotFoundError – If the store does not exist.
ForbiddenStoreNameError – If
store_nameis reserved or not a valid path name.TypeError – If
store_nameis not a str.
- rename(*, to)[source]#
Renames the current store.
- Parameters:
to (str) – The new name of the store.
- Raises:
NotConnectedError – If FeatherStore is not connected to a database.
StoreAlreadyExistsError – If the new store name already exists.
ForbiddenStoreNameError – If the new store name is reserved or not a valid path name.
TypeError – If
tois not a str.
- drop(*, warnings='warn')[source]#
Deletes the current store.
Warning: You cannot delete a store containing tables. All tables must be deleted first.
- Parameters:
warnings (str, optional) – Whether to warn if the store does not exist. Can be
'warn'or'ignore'. Default is'warn'.- Raises:
NotConnectedError – If FeatherStore is not connected to a database.
StoreNotEmptyError – If the store still contains tables.
ForbiddenStoreNameError – If the store name is reserved or not a valid path name.
TypeError – If the store name is not a str.
ValueError – If
warningsis not'warn'or'ignore'.
- list_tables(*, like=None)[source]#
Lists tables in the store.
- Parameters:
like (str, optional) – Filters table names with SQL wildcards.
?matches one character and%matches any number of characters. Matching is case-insensitive. Default isNone.- Returns:
A list of the tables in the store.
- Return type:
- Raises:
NotConnectedError – If FeatherStore is not connected to a database.
TypeError – If
likeis not a str orNone.
- table_exists(table_name)[source]#
Returns whether a table exists in this store.
- Parameters:
table_name (str) – The name of the table.
- Return type:
- Raises:
NotConnectedError – If FeatherStore is not connected to a database.
StoreNotFoundError – If the store does not exist.
ForbiddenTableNameError – If
table_nameis reserved or not a valid path name.TypeError – If
table_nameis not a str.
See also
- read_arrow(table_name, *, cols=None, rows=None, mmap=None)[source]#
Reads a table as a PyArrow Table.
- Parameters:
table_name (str) – The name of the table to read.
cols (Collection, optional) – See
read_arrow().rows (Collection, optional) – See
read_arrow().mmap (bool, optional) – See
read_arrow().
- Return type:
pyarrow.Table
- Raises:
StoreNotFoundError – If the store does not exist.
ForbiddenTableNameError – If
table_nameis reserved or not a valid path name.TypeError – If
table_nameis not a str.
See also
- read_pandas(table_name, *, cols=None, rows=None, mmap=None)[source]#
Reads a table as a pandas DataFrame or Series.
- Parameters:
table_name (str) – The name of the table to read.
cols (Collection, optional) – See
read_pandas().rows (Collection, optional) – See
read_pandas().mmap (bool, optional) – See
read_pandas().
- Return type:
pandas.DataFrame or pandas.Series
- Raises:
StoreNotFoundError – If the store does not exist.
ForbiddenTableNameError – If
table_nameis reserved or not a valid path name.TypeError – If
table_nameis not a str.
See also
- read_polars(table_name, *, cols=None, rows=None, mmap=None)[source]#
Reads a table as a polars DataFrame or Series.
- Parameters:
table_name (str) – The name of the table to read.
cols (Collection, optional) – See
read_polars().rows (Collection, optional) – See
read_polars().mmap (bool, optional) – See
read_polars().
- Return type:
polars.DataFrame or polars.Series
- Raises:
StoreNotFoundError – If the store does not exist.
ForbiddenTableNameError – If
table_nameis reserved or not a valid path name.TypeError – If
table_nameis not a str.
See also
- write_table(table_name, df, /, index=None, *, partition_size=134217728, errors='raise', warnings='warn')[source]#
Writes a DataFrame to the current store as a partitioned table.
- Parameters:
- Raises:
StoreNotFoundError – If the store does not exist.
ForbiddenTableNameError – If
table_nameis reserved or not a valid path name.TypeError – If
table_nameis not a str.
See also
- append_table(table_name, df, *, warnings='warn')[source]#
Appends data to a table.
- Parameters:
- Raises:
StoreNotFoundError – If the store does not exist.
ForbiddenTableNameError – If
table_nameis reserved or not a valid path name.TypeError – If
table_nameis not a str.
See also
- rename_table(table_name, *, to)[source]#
Renames a table.
- Parameters:
- Raises:
NotConnectedError – If FeatherStore is not connected to a database.
StoreNotFoundError – If the store does not exist.
ForbiddenTableNameError – If
table_nameortois reserved or not a valid path name.TableAlreadyExistsError – If the new table name already exists.
TypeError – If
table_nameortois not a str.
See also
- drop_table(table_name, *, warnings='warn')[source]#
Deletes a table.
- Parameters:
- Raises:
NotConnectedError – If FeatherStore is not connected to a database.
StoreNotFoundError – If the store does not exist.
ForbiddenTableNameError – If
table_nameis reserved or not a valid path name.TypeError – If
table_nameis not a str.ValueError – If
warningsis not'warn'or'ignore'.
See also
- select_table(table_name)[source]#
Selects a single table.
Table objects have more features for editing stored tables.
- Parameters:
table_name (str) – The name of the table to return.
- Return type:
- Raises:
NotConnectedError – If FeatherStore is not connected to a database.
StoreNotFoundError – If the store does not exist.
ForbiddenTableNameError – If
table_nameis reserved or not a valid path name.TypeError – If
table_nameis not a str.
See also
- create_snapshot(path)[source]#
Creates a compressed backup of the store.
The store can later be restored with
restore_store().- Parameters:
path (str) – Path to the snapshot archive.
.tar.xzis appended unlesspathalready ends with that suffix. An existing file at the resulting path is overwritten.- Raises:
NotConnectedError – If FeatherStore is not connected to a database.
SnapshotTargetNotFoundError – If the store path does not exist.
TypeError – If
pathis not a str.