IMP
2.4.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 13 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 244 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 255 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 39 of file database.py.
def IMP.EMageFit.database.Database2.close | ( | self | ) |
Closes the database.
Definition at line 194 of file database.py.
def IMP.EMageFit.database.Database2.connect | ( | self, | |
filename | |||
) |
Connects to the database in filename.
Definition at line 32 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 25 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 45 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 144 of file database.py.
def IMP.EMageFit.database.Database2.drop_table | ( | self, | |
table_name | |||
) |
Delete a table if it exists.
Definition at line 61 of file database.py.
def IMP.EMageFit.database.Database2.drop_view | ( | self, | |
view_name | |||
) |
Removes a view from the database.
Definition at line 176 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 200 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 180 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 229 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 211 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 116 of file database.py.
def IMP.EMageFit.database.Database2.select_table | ( | self | ) |
Prompt for tables so the user can choose one.
Definition at line 277 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 94 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 72 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 124 of file database.py.