TrfDatabase¶
- class vallenae.io.TrfDatabase(filename, mode='ro')[source]¶
IO wrapper for trfdb (transient feature) database file.
Methods
__init__(filename[, mode])Open trfdb database file.
close()Close database connection.
columns()Columns of data table.
Get SQLite connection object.
create(filename)Create empty trfdb.
Read fieldinfo table.
Read globalinfo table.
iread(*[, trai, query_filter])Stream features with returned iterable.
listen([existing, wait, query_filter])Listen to database changes and return new records.
read(**kwargs)Read features to Pandas DataFrame.
rows()Number of rows in data table.
tables()Get table names.
write(feature_set)Write feature record to trfdb.
write_fieldinfo(field, info)Write to fieldinfo table.
Attributes
- static create(filename)[source]¶
Create empty trfdb.
- Parameters:
filename (
str) – Path to new trfdb database file
- iread(*, trai=None, query_filter=None)[source]¶
Stream features with returned iterable.
- Parameters:
- Return type:
SizedIterable[FeatureRecord]- Returns:
Sized iterable to sequential read features
- listen(existing=False, wait=False, query_filter=None)[source]¶
Listen to database changes and return new records.
- Parameters:
- Yields:
New feature records
- Return type:
- write(feature_set)[source]¶
Write feature record to trfdb.
- Parameters:
feature_set (
FeatureRecord) – Feature set- Return type:
- Returns:
Index (trai) of inserted row
- close()¶
Close database connection.
- connection()¶
Get SQLite connection object.
- Raises:
RuntimeError – If connection is closed
- Return type:
- fieldinfo()¶
Read fieldinfo table.
The fieldinfo table stores informations about columns of the data table (like units).