db package¶
Subpackages¶
Submodules¶
db.db_tables module¶
Uses ‘sqlalchemy’ library to create a simple ‘sqlite’ db to hold query results for models
-
class
db.db_tables.
KeyValuePairs
(**kwargs)[source]¶ Bases:
sqlalchemy.ext.declarative.api.Base
KeyValuePairs table
Stores key value pairs
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs
.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
-
_decl_class_registry
= <WeakValueDictionary>¶
-
_sa_class_manager
= {'id': <sqlalchemy.orm.attributes.InstrumentedAttribute object at 0x7fc7a7044f68>, 'is_url': <sqlalchemy.orm.attributes.InstrumentedAttribute object at 0x7fc79a5700f8>, 'key': <sqlalchemy.orm.attributes.InstrumentedAttribute object at 0x7fc7a7044fc0>, 'value': <sqlalchemy.orm.attributes.InstrumentedAttribute object at 0x7fc79a5700a0>}¶
-
id
¶
-
is_url
¶
-
key
¶
-
metadata
= MetaData(bind=None)¶
-
value
¶
-
-
class
db.db_tables.
ModelInfo
(**kwargs)[source]¶ Bases:
sqlalchemy.ext.declarative.api.Base
Model_Info table
Any information that comes from the model as a whole, e.g. CRS of the model
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs
.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
-
_decl_class_registry
= <WeakValueDictionary>¶
-
_sa_class_manager
= {'id': <sqlalchemy.orm.attributes.InstrumentedAttribute object at 0x7fc7a7044bf8>, 'json': <sqlalchemy.orm.attributes.InstrumentedAttribute object at 0x7fc7a7044ca8>}¶
-
id
¶
-
json
¶
-
metadata
= MetaData(bind=None)¶
-
-
class
db.db_tables.
PartInfo
(**kwargs)[source]¶ Bases:
sqlalchemy.ext.declarative.api.Base
Part_Info table
Any information derived from a model part e.g. fault surface, borehole
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs
.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
-
_decl_class_registry
= <WeakValueDictionary>¶
-
_sa_class_manager
= {'id': <sqlalchemy.orm.attributes.InstrumentedAttribute object at 0x7fc7a7044a40>, 'json': <sqlalchemy.orm.attributes.InstrumentedAttribute object at 0x7fc7a7044af0>}¶
-
id
¶
-
json
¶
-
metadata
= MetaData(bind=None)¶
-
-
class
db.db_tables.
Query
(**kwargs)[source]¶ Bases:
sqlalchemy.ext.declarative.api.Base
Query table
Basic idea is to have a “query” table that points to the various parts of the model. A website query will provide the name of the model and a label from within the model. This can be used as an index to a row of the table.
The “query” table points to the “info” tables. These point to information at various levels of the model: segments, parts, model, and independent user notes.
At the moment only a simple json string is stored in each of the “info” tables.
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs
.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
-
_decl_class_registry
= <WeakValueDictionary>¶
-
_sa_class_manager
= {'label': <sqlalchemy.orm.attributes.InstrumentedAttribute object at 0x7fc7a7044620>, 'model_info': <sqlalchemy.orm.attributes.InstrumentedAttribute object at 0x7fc7a7044410>, 'model_info_id': <sqlalchemy.orm.attributes.InstrumentedAttribute object at 0x7fc7a7044728>, 'model_name': <sqlalchemy.orm.attributes.InstrumentedAttribute object at 0x7fc7a70445c8>, 'part_info': <sqlalchemy.orm.attributes.InstrumentedAttribute object at 0x7fc7a7044360>, 'part_info_id': <sqlalchemy.orm.attributes.InstrumentedAttribute object at 0x7fc7a70446d0>, 'segment_info': <sqlalchemy.orm.attributes.InstrumentedAttribute object at 0x7fc7a7044308>, 'segment_info_id': <sqlalchemy.orm.attributes.InstrumentedAttribute object at 0x7fc7a7044678>, 'user_info': <sqlalchemy.orm.attributes.InstrumentedAttribute object at 0x7fc7a70444c0>, 'user_info_id': <sqlalchemy.orm.attributes.InstrumentedAttribute object at 0x7fc7a7044780>}¶
-
label
¶
-
metadata
= MetaData(bind=None)¶
-
model_info
¶
-
model_info_id
¶
-
model_name
¶
-
part_info
¶
-
part_info_id
¶
-
segment_info
¶
-
segment_info_id
¶
-
user_info
¶
-
user_info_id
¶
-
-
class
db.db_tables.
QueryDB
(create=False, db_name='query_data.db')[source]¶ Bases:
object
A simple database class to manage the creation, writing and reading of the query database
-
add_model
(json_str)[source]¶ Adds a model object to database
Parameters: json_str – model object as a JSON string Returns: a tuple (True, model_obj) if successful (False, exception string) if operation failed
-
add_part
(json_str)[source]¶ Adds a part object to database
Parameters: json_str – part object as a JSON string Returns: a tuple (True, partinfo_obj) if successful (False, exception string) if operation failed
-
add_query
(label, model_name, segment, part, model, user)[source]¶ Adds a query object to database
Parameters: json_str – query object as a JSON string Returns: a tuple (True, query_obj) if successful (False, exception string) if operation failed
-
add_segment
(json_str)[source]¶ Adds a segment object to database
Parameters: json_str – segment object as a JSON string Returns: a tuple (True, seginfo_obj) if successful (False, exception string) if operation failed
-
-
class
db.db_tables.
SegmentInfo
(**kwargs)[source]¶ Bases:
sqlalchemy.ext.declarative.api.Base
Segment_Info table
Any information derived from a segment within a 3d model part, e.g. a single triangle on a fault surface made of lots of triangles
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs
.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
-
_decl_class_registry
= <WeakValueDictionary>¶
-
_sa_class_manager
= {'id': <sqlalchemy.orm.attributes.InstrumentedAttribute object at 0x7fc7a7044888>, 'json': <sqlalchemy.orm.attributes.InstrumentedAttribute object at 0x7fc7a7044938>}¶
-
id
¶
-
json
¶
-
metadata
= MetaData(bind=None)¶
-
-
class
db.db_tables.
UserInfo
(**kwargs)[source]¶ Bases:
sqlalchemy.ext.declarative.api.Base
User_Info table
Any user notes that must be kept separate from the model data update process e.g. links to external databases
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs
.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
-
_decl_class_registry
= <WeakValueDictionary>¶
-
_sa_class_manager
= {'id': <sqlalchemy.orm.attributes.InstrumentedAttribute object at 0x7fc7a7044db0>, 'json': <sqlalchemy.orm.attributes.InstrumentedAttribute object at 0x7fc7a7044e60>}¶
-
id
¶
-
json
¶
-
metadata
= MetaData(bind=None)¶
-