| |
Methods defined here:
- __getnewargs__(self)
- __getstate__(self)
- __init__(self, dbname=None, dbhost=None, dbuser=None, dbpassword=None)
- __setstate__(self, dict)
- insert_db_content(self, sql_query, answer_mode=None)
- Inserts values into a piana database (connection was established in self.db)
Depending on argument "answer_mode", different things are returned.
This method is called by PianaDBaccess to then process the results and return them to the user
"slq_query" is normally obtained through classes implemented in PianaInsertSQL.py, which have a method get_sqlquery
that creates the sql query needed to retrieve the searched value.
"answer_mode" can be one of the following:
- None: nothing is returned
- 'last_id' : last id inserted is returned
- 'num_updated' : number of rows that were updated (used by UPDATE statements...)
--> 'last_id' mode only works for those tables that have an auto_increment ID!!!!!!! Will not work with primary keys that are not
auto_increment. Currently, following tables have auto_increment ids: protein (ID=proteinPiana) and interaction (ID=interactionPiana)
- select_db_content(self, sql_query=None, answer_mode='single', remove_duplicates='yes', number_of_selected_elems=1)
- Returns content from a piana database (connection was established in self.db)
"slq_query" is normally obtained through classes implemented in PianaSelectSQL.py, which have a method get_sqlquery
that creates the sql query needed to retrieve the searched value
"answer_mode" is used to let the user choose what kind of answer he is expecting from the sql query
answer_mode can take values (default is "single"):
- "single": just one element (if nothing is found, returns None)
- "list": a list of single elements (if nothing is found, returns empty list [])
- "raw": the raw result from the sql query (a matrix)
"remove_duplicates" is used to let the user decide if the returning list can contain duplicates or not
(only used when answer_mode="list")
(this is useful to remove similar entries from one query, for example same uniprot accession numbers returned
that are actually the same under different swissAccession source DB )
- "yes" will return a list where all elements are unique
- "no" will return the complete list returned by the sql query
"number_of_selected_elems" sets the number of elements being selected in the sql query.
- If 1, only the string of the element is returned.
- If >1, each group of elements is represented by a tuple (elem1, elem2, ...)
- if you want to use a number_of_selected_elems higher than 3, you have to modify the code below
to create keys of the number of elements you wish to select
Data and other attributes defined here:
- __dict__ = <dictproxy object>
- dictionary for instance variables (if defined)
- __weakref__ = <attribute '__weakref__' of 'PianaDB' objects>
- list of weak references to the object (if defined)
|