3.1.1.1. thyrsis.database package

3.1.1.1.2. Module contents

Thyrsis spatialite database structure

USAGE

python -m thyrsis.database siteName simulationName ouput.sqlite

create a computation db from template

class thyrsis.database.DebugCursor(cur)

Bases : object

Unused

execute(sql)
executemany(sql, arg)
fetchall()
fetchone()
thyrsis.database.add_second_milieu(database)

Copy existing table to create a dual-porosity simulation

Paramètres

database (string) – database path

thyrsis.database.create_computation_database(database, mesh_db=None, simulation_name=None)

Create a computation database from a mesh site

Paramètres
  • database (string) – database path

  • mesh_db (string) – mesh database path

  • simulation_name (string) – simulation name

thyrsis.database.create_injection_triggers(cur)

Create injection triggers in the current database

Paramètres

cur (sqlite3.Cursor) – cursor on a sqlite connection

thyrsis.database.create_latin_hypercube(cur, nombre_de_simulations=1)

Use latin hypercube to create n simulations

Paramètres
  • cur (sqlite3.Cursor) – cursor on a sqlite connection

  • nombre_de_simulations (integer) – n simulations

thyrsis.database.create_mesh_tables(cur, project_SRID=None)

create tables for mesh (noeuds and mailles) The spatial index of maille may be corrupted by inserts/update

Paramètres
  • cur (sqlite3.Cursor) – cursor on a sqlite connection

  • project_SRID (string) – EPSG code

thyrsis.database.create_metadata_table(cur)

Create metadata table in the current database

Paramètres

cur (sqlite3.Cursor) – cursor on a sqlite connection

thyrsis.database.create_site_tables(cur, with_cid=False, project_SRID=None)

create site tables without cid and sid columns (only one site and one simulation

Paramètres
  • cur (sqlite3.Cursor) – cursor on a sqlite connection

  • with_cid (bool) – cid option, create a cid column in tables

  • project_SRID (string) – EPSG code

thyrsis.database.database_type(cur)

return database type

Paramètres

cur (sqlite3.Cursor) – cursor on a sqlite connection

Renvoie

db_type

Type renvoyé

string

thyrsis.database.db_elem_to_node(cur, column, elem_values)

updates nodes table from mesh table

Paramètres
  • cur (sqlite3.Cursor) – cursor on a sqlite connection

  • column (string) – column name

  • elem_values (list) – list of element value for a column

thyrsis.database.db_node_to_elem(cur, column, node_values)

updates mesh table from nodes table

Paramètres
  • cur (sqlite3.Cursor) – cursor on a sqlite connection

  • column (string) – column name

  • node_values (list) – list of node value for a column

thyrsis.database.delete_injection_triggers(cur)

Delete injection triggers in the current database

Paramètres

cur (sqlite3.Cursor) – cursor on a sqlite connection

thyrsis.database.delete_mesh(cur, test=False)

Delete mesh data in the current database

Paramètres

cur (sqlite3.Cursor) – cursor on a sqlite connection

thyrsis.database.delete_results(cur)

Delete result tables in the current database

Paramètres

cur (sqlite3.Cursor) – cursor on a sqlite connection

thyrsis.database.elem_to_node(noeuds, mailles, elem_values)

returns node values with format ((value, id), …)

Paramètres
  • noeuds (list) – nodes

  • mailles (list) – mesh elements

  • elem_values (list) – list of element value for a column

Renvoie

nodes values

Type renvoyé

list

thyrsis.database.export_simulation(src, dst)

export the simulation in src to the site database

Paramètres
  • src (string) – source database path

  • dst (string) – destination database path

thyrsis.database.has_second_milieu(cur)

Check if the current database is made for dual-porosity simulation

Paramètres

cur (sqlite3.Cursor) – cursor on a sqlite connection

thyrsis.database.mesh_tables_exists(cur)

test if mesh tables exist

Paramètres

cur (sqlite3.Cursor) – cursor on a sqlite connection

Renvoie

success state

Type renvoyé

bool

thyrsis.database.node_to_elem(mailles, node_values)

returns mesh values with format ((value, id), …)

Paramètres
  • mailles (list) – mesh elements

  • node_values (list) – list of node value for a column

Renvoie

mesh values

Type renvoyé

list

thyrsis.database.parametres_simulation_exists(cur)

Check if the simulation parameters exists

Paramètres

cur (sqlite3.Cursor) – cursor on a sqlite connection

Renvoie

success state

Type renvoyé

bool

thyrsis.database.set_default_param(database)

set default parameter

Paramètres

database (string) – database path

thyrsis.database.simulation_mesh(cur, simulation)

Get mesh name from simulation table

Paramètres
  • cur (sqlite3.Cursor) – cursor on a sqlite connection

  • simulation (string) – simulation name

Renvoie

nom_db_maillage

Type renvoyé

string

thyrsis.database.upgrade(database)

upgrade database to current schema version, raise exception if not possible do nothing if the version is already OK

Paramètres

database (string) – database path

thyrsis.database.upgrade_none_to_180321(src, dst, project_SRID=None)

upgrade database to 18.03.21 schema version, raise exception if not possible do nothing if the version is already OK

Paramètres
  • src (string) – source database path

  • dst (string) – destination database path

  • project_SRID (string) – EPSG code

thyrsis.database.version(cur)

return db version, None if metadata is not there

Paramètres

cur (sqlite3.Cursor) – cursor on a sqlite connection

Renvoie

db version

Type renvoyé

string