SQLStore#
- class linkml.utils.sqlutils.SQLStore(schema: str | Path | SchemaDefinition | None = None, schemaview: SchemaView | None = None, engine: Engine | None = None, database_path: str | Path | None = None, use_memory: bool = False, module: module | None = None, native_module: module | None = None, include_schema_in_database: bool = False, **_kwargs)[source]#
A wrapper for a SQLite database.
This provides two core operations for storing and retrieving data
The wrapper transparently will take care of:
mapping your LinkML schema into SQL Tables
creating a SQL Alchemy ORM layer
mapping your data/objects in any LinkML compliant data format (json. yaml, rdf) into ORM objects
- compile() module [source]#
Compile SQLAlchemy object model
Uses Declarative by default.
Note that the SQLA model is different from the native dataclass model
- Returns:
compiled module
- db_exists(create=True, force=False) str | None [source]#
check if database exists, optionally create if not present
- Parameters:
create – create if does not exist
force – recreate database, destroying any content if previously present
- Returns:
path
- dump(element: YAMLRoot, append=True) None [source]#
Store an element in the database
- Parameters:
element –
append –
- Returns:
- from_sqla(obj: Any) YAMLRoot | List[YAMLRoot] | None [source]#
Translate from SQLAlchemy declarative module to native LinkML
- Parameters:
obj – sqla object
- Returns:
native dataclass object
- load(target_class: str | Type[YAMLRoot] | None = None) YAMLRoot [source]#
Loads a LinkML object from the wrapped SQLite database
- Parameters:
target_class –
- Returns:
Command Line#
linkml-sqldb#
Run the LinkML SQL CLI.
linkml-sqldb [OPTIONS] COMMAND [ARGS]...
Options
- -v, --verbose#
- -q, --quiet <quiet>#
- --csv-field-size-limit <csv_field_size_limit>#
Increase the default limit for maximum field size. See https://docs.python.org/3/library/csv.html#csv.field_size_limit
- -V, --version#
Show the version and exit.
Commands
- dump
Dumps data to a SQL store
- load
Loads data from a SQL store