ftmq.store
PreservingLinker
Bases: Linker[StatementEntity]
A linker that answers with the canonical id a statement already carries.
Backend writers stamp canonical_id from the store's linker: point the store
at this one and preserve each
statement before writing it to keep its canonical id. Any other id (such as
entity-typed values) maps to itself.
Source code in ftmq/store/base.py
Store
Bases: Store[Dataset, StatementEntity]
Feature add-ons to nomenklatura.store.Store.
Source code in ftmq/store/base.py
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 | |
scope
property
The read scope: the explicit dataset, or all datasets in the store.
__init__(dataset=None, linker=None, cast_types=True, **kwargs)
Initialize a store, use get_store instead.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset
|
Dataset | str | None
|
A |
None
|
linker
|
Linker | None
|
A |
None
|
cast_types
|
bool
|
Normalize statement values on write (see
|
True
|
Source code in ftmq/store/base.py
casting_writer(writer)
Rebless a backend writer so it casts statement values on write.
A store that builds its writer itself has to route it through here.
Source code in ftmq/store/base.py
get_scope()
iterate(dataset=None)
Iterate all the entities, optionally limited to a dataset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset
|
str | Dataset | None
|
|
None
|
Yields:
| Type | Description |
|---|---|
StatementEntities
|
Generator of |
Source code in ftmq/store/base.py
statements(dataset=None)
Iterate the raw statements in this store, as they are stored.
Unlike iterate (entity assembly
rewrites values and synthesizes an id statement), a dump of these
loads back onto its own rows. Includes external statements, unordered.
SQL family only.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset
|
str | Dataset | None
|
|
None
|
Yields:
| Type | Description |
|---|---|
Statements
|
Generator of |
Source code in ftmq/store/base.py
writer(*args, **kwargs)
The backend writer, casting statement values on write.
Values are cast into their property type's canonical format (see
ftmq.statements), values that don't parse pass
through unchanged. Disable with the store's cast_types=False.
Source code in ftmq/store/base.py
View
Bases: View[Dataset, StatementEntity]
Feature add-ons to nomenklatura.store.base.View.
Source code in ftmq/store/base.py
query(query=None)
Get the entities of the view, optionally filtered by a Query.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
Query | None
|
The Query filter object |
None
|
Yields:
| Type | Description |
|---|---|
StatementEntities
|
Generator of |
Source code in ftmq/store/base.py
get_engine(uri=None)
The process-wide engine for a sql database uri.
An in-memory sqlite url gets one shared, thread-safe engine, so every store and resolver on it sees the same database.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uri
|
str | None
|
A sql database uri, defaults to |
None
|
Source code in ftmq/store/base.py
get_linker(uri)
cached
A read-only Linker (merge decisions only) for read paths such as the api.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uri
|
Uri
|
A sql database uri with a nomenklatura |
required |
Returns:
| Type | Description |
|---|---|
Linker[StatementEntity]
|
The linker. This is a cached object. |
Source code in ftmq/store/base.py
get_preserving_linker()
cached
The process-wide PreservingLinker.
Cached, as get_store keys its cache on the linker. It tracks one statement
at a time, so concurrent statement writes into two stores are not supported.
Source code in ftmq/store/base.py
get_resolver(uri=None)
cached
The read/write Resolver backed by a sql resolver table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uri
|
str | None
|
A sql database uri. Anything else (or nothing) gets an ephemeral in-memory table. |
None
|
Returns:
| Type | Description |
|---|---|
Resolver[StatementEntity]
|
The resolver, with its decisions loaded. Cached and never refreshed:
call |