mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-16 13:46:54 +00:00
Further defer sql.py imports for ifcopenbot to succeed
This commit is contained in:
@@ -1,19 +1,20 @@
|
|||||||
try:
|
try:
|
||||||
import re
|
import re
|
||||||
import json
|
import json
|
||||||
import sqlite3
|
|
||||||
# import mysql.connector
|
|
||||||
import numpy as np
|
|
||||||
import ifcopenshell.util.schema
|
import ifcopenshell.util.schema
|
||||||
from .file import file
|
from .file import file
|
||||||
from . import ifcopenshell_wrapper
|
from . import ifcopenshell_wrapper
|
||||||
from .entity_instance import entity_instance
|
from .entity_instance import entity_instance
|
||||||
except:
|
except ImportError as e:
|
||||||
|
print(f"No SQL support: {e}")
|
||||||
pass # No SQL support
|
pass # No SQL support
|
||||||
|
|
||||||
|
|
||||||
class sqlite(file):
|
class sqlite(file):
|
||||||
def __init__(self, filepath):
|
def __init__(self, filepath):
|
||||||
|
import sqlite3
|
||||||
|
|
||||||
self.wrapped_data = None
|
self.wrapped_data = None
|
||||||
self.history_size = 64
|
self.history_size = 64
|
||||||
self.history = []
|
self.history = []
|
||||||
@@ -24,6 +25,7 @@ class sqlite(file):
|
|||||||
self.db = sqlite3.connect(self.filepath)
|
self.db = sqlite3.connect(self.filepath)
|
||||||
self.db.row_factory = sqlite3.Row
|
self.db.row_factory = sqlite3.Row
|
||||||
|
|
||||||
|
# import mysql.connector
|
||||||
# self.db = mysql.connector.connect(
|
# self.db = mysql.connector.connect(
|
||||||
# host="localhost",
|
# host="localhost",
|
||||||
# user="root",
|
# user="root",
|
||||||
@@ -198,6 +200,8 @@ class sqlite(file):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def get_geometry(self, ids):
|
def get_geometry(self, ids):
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
ids_csv = ",".join(map(str, ids))
|
ids_csv = ",".join(map(str, ids))
|
||||||
query = f"SELECT ifc_id, x, y, z, matrix, geometry, verts, edges, faces, material_ids, materials FROM shape LEFT JOIN geometry ON shape.geometry = geometry.id WHERE `ifc_id` IN ({ids_csv})"
|
query = f"SELECT ifc_id, x, y, z, matrix, geometry, verts, edges, faces, material_ids, materials FROM shape LEFT JOIN geometry ON shape.geometry = geometry.id WHERE `ifc_id` IN ({ids_csv})"
|
||||||
self.cursor.execute(query)
|
self.cursor.execute(query)
|
||||||
|
|||||||
Reference in New Issue
Block a user