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, use_memory: bool = False, module: ModuleType | None = None, native_module: ModuleType | None = None, include_schema_in_database: bool = False)[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() ModuleType [source]¶
Compile SQLAlchemy object model
Uses Declarative by default.
Note that the SQLA model is different from the native dataclass model
- Returns:
compiled module
- compile_native() ModuleType [source]¶
Compile native python object 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) 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