| 382 | self.c.execute(statement) |
| 383 | |
| 384 | def create_metadata(self) -> None: |
| 385 | # There is no "standard" SQL serialisation, so we propose a convention |
| 386 | # of a "metadata" table to hold high level metadata. This includes the |
| 387 | # preprocessor field to uniquely identify the "variant" of SQL schema |
| 388 | # used. If someone wants their own SQL schema variant, they can |
| 389 | # identify it using the preprocessor field. |
| 390 | # IfcOpenShell-1.0.0 represents a schema where 1 table = 1 declaration. |
| 391 | # IfcOpenShell-2.0.0 represents a schema where tables represent types. |
| 392 | metadata = ["IfcOpenShell-1.0.0", self.file.schema, self.file.header.file_description.description[0]] |
| 393 | if self.sql_type == "sqlite": |
| 394 | statement = "CREATE TABLE IF NOT EXISTS metadata (preprocessor text, schema text, mvd text);" |
| 395 | self.c.execute(statement) |
| 396 | self.c.execute("INSERT INTO metadata VALUES (?, ?, ?);", metadata) |
| 397 | elif self.sql_type == "mysql": |
| 398 | statement = """ |
| 399 | CREATE TABLE `metadata` ( |
| 400 | `preprocessor` varchar(255) NOT NULL, |
| 401 | `schema` varchar(255) NOT NULL, |
| 402 | `mvd` varchar(255) NOT NULL |
| 403 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci; |
| 404 | """ |
| 405 | self.c.execute(statement) |
| 406 | self.c.execute("INSERT INTO metadata VALUES (%s, %s, %s);", metadata) |
| 407 | |
| 408 | def create_pset_table(self) -> None: |
| 409 | statement = """ |