Home | Trees | Indices | Help |
|
---|
|
Class for establishing conexions to pianaDB and handling inserts and selects
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
Inherited from |
|
|||
Inherited from |
|
"dbname" is the database name to which you want to connect to (required) "dbhost" is the machine with the mysql server that holds the piana database (required) "dbuser" is the mysql user (not required in most systems) "dbpassword" is the mysql password (not required in most systems) "dbport" is the mysql port (not required in most systems) "buffer" determines if an insert buffer is going to be used. Default is True. Alert! DB Object must be closed before in order to empty the buffer! Buffer is used due to performance when parsing data "lock_tables" is used to lock the used tables
|
str(x)
|
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) "buffer" indicates if this sql_query has to be inserted or not. It can be: - None: sql_query will be treated as a sql_query and it will be executed (if possible) - dictionary: the insert has been inserted into the dictionary buffer. So, the sql_query will not be executed. (So, sql_query can be None too. It will be ignored. |
: 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 |
Method for checking database It checks if all tables are existing It does not drop any table For the moment, it does not check default value of table fields |
Generates a general select sql statement "tables" is a list or tuple of tables where the value/s must be searched. If the elements of the list or tuple are tuples of length 2, the format taken will be the following: (table_name or table_object, alias to the table) "columns" is a list or tuple of the columns searched (columns must be preceeded by the table where they are searched). If it is None, all values will be selected "fixed_conditions" is a list or tuple of tuples with the following format: (column,type,restriction_value) "join_conditions" is a list or tuple of tuples with the following format: (column,type,column) to restrict the selection to the joint "type" can be "=",">","<",... "group_conditions" is a list of columns where it must be grouped It returns the sql query. |
Generates a general delete sql statement "table" is a table name or table object "fixed_conditions" is a list or tuple of tuples with the following format: (column,type,restriction_value) "type" can be "=",">","<",... It returns the sql query. |
Generates a general sql statement "column_values" must be a tuple of tuples with the following format: (column, value) It returns the sql query. It does not use the buffer! By default, if the buffer is active, it will use the buffer, unless the "use_buffer" atributte is set to False It can return a list of queries instead a single query in the case the buffer is being used "max_elements_in_buffer" is only used when buffer is used. It is not mandatory "on_duplicate_key" specifies the query to be used when duplicate keys exists |
Returns all queries of insert buffer and empties it If key_buffer is None, it generates all the queries to empty the buffer. Otherwise, it will insert only the key specified |
"columns" must be a tuple with the name of the columns "values" must be a Set of tuples of values to insert |
Returns False if it is not using buffer Otherwise return true |
Method used to Lock tables. Insertions are faster if tables are previously locked. table_list is a list of table names |
Generates the SQL statement that unlocks tables previously locked Method used to return the SQL query that locks access to mysql tables. Insertions are faster if tables are previously locked. table_list is a list of table names |
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Tue May 26 17:06:25 2009 | http://epydoc.sourceforge.net |