DatabaseManager
[source]¶Internally manages the database engine and any sql related objects. Hands out sessions with getSession() but only offers abstractions for other functionality. The database is INDEPENDENT from the application
commit_to_db
(poly_list, time)[source]¶Takes a list of polygons and commits them into the database, used in polygonList to commit all visible polygons
Parameters: |
|
---|
delete_item
(idx)[source]¶Get a session and delete the object from the database.
Parameters: | idx – the primary key for the object passed |
---|
dump_to_json
(zip_fname)[source]¶Dump the contents of the database into a JSON file with the specific format
of DatabasePolygon. Creates a directory ‘{PROJECT}/tmp’ and exports all db
objects to it, then zips the directory and deletes tmp. Returns True
on
success, False
otherwise
Parameters: | zip_fname (str) – name of the zip file |
---|---|
Return type: | bool |
encode
(filename, data)[source]¶Encode and write out a JSON object
Parameters: |
|
---|
exists_tag
(tag)[source]¶Check the database if a tag currently exists, if so return True, else return False
Return type: | bool |
---|
get_session
()[source]¶Returns an instance of a session, USERS job to ensure session is committed/closed
import_from_json
(zip_fname)[source]¶Import a .zip file selected by the user, the zip file must be
the same format as how dump_to_json
creates a zip, otherwise
an error will be raised. Uses functionality similar to ShapeReader
,
but as db should never be dependent on another class we need to
impl our own import method. The big difference here is that shapes
are not added to the current shape list, instead are only loaded into
the local database.
Return type: | bool |
---|
DatabasePolygon
(**kwargs)[source]¶Sqlalchemy class object, contains all data that is stored inside the database. Objects are represented as JSON
id
¶tag
¶color
¶time_
¶hdf
¶plot
¶attributes
¶coordinates
¶notes
¶dbBase
= <class 'sqlalchemy.ext.declarative.api.Base'>¶The most base type
db
= <db.DatabaseManager object>¶Internally manages the database engine and any sql related objects. Hands out sessions with getSession() but only offers abstractions for other functionality. The database is INDEPENDENT from the application