ifcpatch.recipes.Ifc2Sql
¶
Module Contents¶
- class ifcpatch.recipes.Ifc2Sql.Patcher(file: ifcopenshell.file, logger: logging.Logger | None = None, sql_type: SQLTypes = 'SQLite', host: str = 'localhost', username: str = 'root', password: str = 'pass', database: str = DEFAULT_DATABASE_NAME, full_schema: bool = True, is_strict: bool = False, should_expand: bool = False, should_get_inverses: bool = True, should_get_psets: bool = True, should_get_geometry: bool = True, should_skip_geometry_data: bool = False)¶
Bases:
ifcpatch.BasePatcher
Convert an IFC-SPF model to SQLite or MySQL.
- Parameters:
sql_type – Choose between “SQLite” or “MySQL”
database – Database filepath / name. For SQLite - database path to save the SQL database to (already existing or not). Could also be a directory, then the database will be stored using default filename (e.g. ‘database.sqlite’). If filepath is missing fitting suffix, it will be added. For MySQL - database name.
full_schema – if True, will create tables for all IFC classes, regardless if they are used or not in the dataset. If False, will only create tables for classes in the dataset.
is_strict – whether or not to enforce null or not null. If your dataset might contain invalid data, set this to False.
should_expand – if True, entities with attributes containing lists of entities will be separated into multiple rows. This means the ifc_id is no longer a unique primary key. If False, lists will be stored as JSON.
should_get_inverses – if True, a list of entity inverses ids will be stored in a separate column as a json string.
should_get_psets – if True, a separate psets table will be created to make it easy to query properties. This is in addition to regular IFC tables like IfcPropertySet.
should_get_geometry – Whether or not to process and store explicit geometry data as a blob in a separate geometry and shape table.
should_skip_geometry_data – Whether or not to also create tables for IfcRepresentation and IfcRepresentationItem classes. These tables are unnecessary if you are not interested in geometry.
- Filter_glob database:
.db;.sqlite
Example:
# Convert to SQLite, SQLite databse will be saved to a temporary file. sqlite_temp_filepath = ifcpatch.execute( {"input": "input.ifc", "file": model, "recipe": "Ifc2Sql", "arguments": ["sqlite"]} )
- check_existing_ifc_database() None ¶
- create_geometry() None ¶
- create_geometry_table() None ¶
- create_id_map() None ¶
- create_metadata() None ¶
- create_mysql_table(ifc_class: str, declaration: ifcopenshell.ifcopenshell_wrapper.declaration) None ¶
- create_pset_table() None ¶
- create_sqlite_table(ifc_class: str, declaration: ifcopenshell.ifcopenshell_wrapper.declaration) None ¶
- get_output() str | None ¶
Return resulting database filepath for sqlite and
None
for mysql.
- get_permutations(lst: list[Any], indexes: list[int]) list[Any] ¶
Original row (lst):
` ifc_id, x, (a, b), (c,d) `
Resulting permutations:
` ifc_id, x, a, c ifc_id, x, a, d ifc_id, x, b, c ifc_id, x, b, d `
- insert_data(ifc_class: str) None ¶
- is_entity_list(attribute: ifcopenshell.ifcopenshell_wrapper.attribute) bool ¶
- patch() None ¶
- serialise_value(element: ifcopenshell.entity_instance, value: Any) Any ¶
- database = 'database'¶
- full_schema = True¶
- geometry_rows: dict[str, tuple[str, bytes, bytes, bytes, bytes, str]]¶
- host = 'localhost'¶
- is_strict = False¶
- logger = None¶
- my_sql_classes_json_attrs: dict[str, list[int]]¶
Mapping ifc_class -> list of attr indices.
Needed to mark json attributes that should be converted to string explicitly (mysql doesn’t convert them automatically, unlike sqlite)
- password = 'pass'¶
- shape_rows: dict[int, tuple[int, list[float], list[float], list[float], bytes, str]]¶
- should_expand = False¶
- should_get_geometry = True¶
- should_get_inverses = True¶
- should_get_psets = True¶
- should_skip_geometry_data = False¶
- sql_type: Literal['sqlite', 'mysql'] = ''¶
- username = 'root'¶
- ifcpatch.recipes.Ifc2Sql.DEFAULT_DATABASE_NAME = 'database'¶
- ifcpatch.recipes.Ifc2Sql.SQLTypes¶
- ifcpatch.recipes.Ifc2Sql.SQLTypes¶