IMP Reference Guide
2.17.0
The Integrative Modeling Platform
|
Class to manage a SQL database built with sqlite3. More...
Class to manage a SQL database built with sqlite3.
Definition at line 16 of file database.py.
Public Member Functions | |
def | add_column |
Add a column to a table column - the name of the column. More... | |
def | add_columns |
Add columns to the database. More... | |
def | check_if_is_connected |
Checks if the class is connected to the database filename. More... | |
def | close |
Closes the database. More... | |
def | connect |
Connects to the database in filename. More... | |
def | create |
Creates a database by simply connecting to the file. More... | |
def | create_table |
Creates a table. More... | |
def | create_view |
creates a view of the given table where the values are selected using the condition values. More... | |
def | drop_table |
Delete a table if it exists. More... | |
def | drop_view |
Removes a view from the database. More... | |
def | get_condition_string |
creates a condition applying each value to each field More... | |
def | get_table |
Returns th fields requested from the table. More... | |
def | get_table_column_names |
Get the names of the columns for a given table. More... | |
def | get_table_types |
Gets info about a table and retuns all the types in it. More... | |
def | retrieve_data |
Retrieves data from the database using the sql_command returns the records as a list of tuples. More... | |
def | select_table |
Prompt for tables so the user can choose one. More... | |
def | store_data |
Inserts information in a given table of the database. More... | |
def | store_dataV1 |
Inserts information in a given table of the database. More... | |
def | update_data |
updates the register in the table identified by the condition values for the condition fields More... | |
def IMP.EMageFit.database.Database2.add_column | ( | self, | |
table, | |||
column, | |||
data_type | |||
) |
Add a column to a table column - the name of the column.
data_type - the type: int, float, str
Definition at line 246 of file database.py.
def IMP.EMageFit.database.Database2.add_columns | ( | self, | |
table, | |||
names, | |||
types, | |||
check = True |
|||
) |
Add columns to the database.
If check=True, columns with names already in the database are skipped. If check=False no check is done and trying to add a column that already exists will raise and exception
Definition at line 257 of file database.py.
def IMP.EMageFit.database.Database2.check_if_is_connected | ( | self | ) |
Checks if the class is connected to the database filename.
Definition at line 42 of file database.py.
def IMP.EMageFit.database.Database2.close | ( | self | ) |
Closes the database.
Definition at line 196 of file database.py.
def IMP.EMageFit.database.Database2.connect | ( | self, | |
filename | |||
) |
Connects to the database in filename.
Definition at line 35 of file database.py.
def IMP.EMageFit.database.Database2.create | ( | self, | |
filename, | |||
overwrite = False |
|||
) |
Creates a database by simply connecting to the file.
Definition at line 28 of file database.py.
def IMP.EMageFit.database.Database2.create_table | ( | self, | |
table_name, | |||
column_names, | |||
column_types | |||
) |
Creates a table.
It expects a sorted dictionary of (data_field,typename) entries
Definition at line 48 of file database.py.
def IMP.EMageFit.database.Database2.create_view | ( | self, | |
view_name, | |||
table_name, | |||
condition_fields, | |||
condition_values | |||
) |
creates a view of the given table where the values are selected using the condition values.
See the help for update_data()
Definition at line 145 of file database.py.
def IMP.EMageFit.database.Database2.drop_table | ( | self, | |
table_name | |||
) |
Delete a table if it exists.
Definition at line 64 of file database.py.
def IMP.EMageFit.database.Database2.drop_view | ( | self, | |
view_name | |||
) |
Removes a view from the database.
Definition at line 178 of file database.py.
def IMP.EMageFit.database.Database2.get_condition_string | ( | self, | |
fields, | |||
values | |||
) |
creates a condition applying each value to each field
Definition at line 202 of file database.py.
def IMP.EMageFit.database.Database2.get_table | ( | self, | |
table_name, | |||
fields = False , |
|||
orderby = False |
|||
) |
Returns th fields requested from the table.
Definition at line 182 of file database.py.
def IMP.EMageFit.database.Database2.get_table_column_names | ( | self, | |
name | |||
) |
Get the names of the columns for a given table.
Definition at line 231 of file database.py.
def IMP.EMageFit.database.Database2.get_table_types | ( | self, | |
name | |||
) |
Gets info about a table and retuns all the types in it.
Definition at line 213 of file database.py.
def IMP.EMageFit.database.Database2.retrieve_data | ( | self, | |
sql_command | |||
) |
Retrieves data from the database using the sql_command returns the records as a list of tuples.
Definition at line 117 of file database.py.
def IMP.EMageFit.database.Database2.select_table | ( | self | ) |
Prompt for tables so the user can choose one.
Definition at line 279 of file database.py.
def IMP.EMageFit.database.Database2.store_data | ( | self, | |
table_name, | |||
data | |||
) |
Inserts information in a given table of the database.
The info must be a list of tuples containing as many values as columns in the table Conversion of values is done AUTOMATICALLY after checking the types stored in the table
Definition at line 95 of file database.py.
def IMP.EMageFit.database.Database2.store_dataV1 | ( | self, | |
table_name, | |||
data | |||
) |
Inserts information in a given table of the database.
The info must be a list of tuples containing as many values as columns in the table Conversion of values is done AUTOMATICALLY after checking the types stored in the table
Definition at line 75 of file database.py.
def IMP.EMageFit.database.Database2.update_data | ( | self, | |
table_name, | |||
updated_fields, | |||
updated_values, | |||
condition_fields, | |||
condition_values | |||
) |
updates the register in the table identified by the condition values for the condition fields
Definition at line 125 of file database.py.