fandango.db module¶
Description¶
This package implements a simplified acces to MySQL using FriendlyDB object.
Go to http://mysql-python.sourceforge.net/MySQLdb.html for further information
Classes¶
FriendlyDB¶
- class fandango.db.FriendlyDB(db_name, host='', user='', passwd='', autocommit=True, loglevel='WARNING', use_tuples=False, default_cursor=None)[source]¶
Class for managing direct access to MySQL databases using mysql-python module
- Query(query, export=True, asDict=False)[source]¶
Executes a query directly in the database @param query SQL query to be executed @param export If it’s True, it returns directly the values instead of a cursor @return the executed cursor, values can be retrieved by executing cursor.fetchall()
- Select(what, tables, clause='', group='', order='', limit='', distinct=False, asDict=False, trace=False)[source]¶
Allows to create and execute Select queries using Lists as arguments @return depending on param asDict it returns a list or lists or a list of dictionaries with results
- fetchall(cursor=None)[source]¶
This method provides a custom replacement to cursor.fetchall() method. It is used to return a list instead of a big tuple; what seems to cause trouble to python garbage collector.
- getCursor(renew=True, klass=None)[source]¶
returns the Cursor for the database renew will force the creation of a new cursor object klass may be any of MySQLdb.cursors classes (e.g. DictCursor) MySQLdb.cursors.SSCursor allows to minimize mem usage in clients (although it relies memory cleanup to the server!)
- getTableCols(table)[source]¶
Returns the column names for the given table, and stores these values in the tables dict.
raw autodoc¶
- class fandango.db.FriendlyDB(db_name, host='', user='', passwd='', autocommit=True, loglevel='WARNING', use_tuples=False, default_cursor=None)[source]
Bases: fandango.log.Logger
Class for managing direct access to MySQL databases using mysql-python module
- Query(query, export=True, asDict=False)[source]
Executes a query directly in the database @param query SQL query to be executed @param export If it’s True, it returns directly the values instead of a cursor @return the executed cursor, values can be retrieved by executing cursor.fetchall()
- Select(what, tables, clause='', group='', order='', limit='', distinct=False, asDict=False, trace=False)[source]
Allows to create and execute Select queries using Lists as arguments @return depending on param asDict it returns a list or lists or a list of dictionaries with results
- fetchall(cursor=None)[source]
This method provides a custom replacement to cursor.fetchall() method. It is used to return a list instead of a big tuple; what seems to cause trouble to python garbage collector.
- getCursor(renew=True, klass=None)[source]
returns the Cursor for the database renew will force the creation of a new cursor object klass may be any of MySQLdb.cursors classes (e.g. DictCursor) MySQLdb.cursors.SSCursor allows to minimize mem usage in clients (although it relies memory cleanup to the server!)
- getTableCols(table)[source]
Returns the column names for the given table, and stores these values in the tables dict.
- getTables(load=False)[source]
Initializes the keys of the tables dictionary and returns these keys.
- setUser(user, passwd)[source]
Set User and Password to access MySQL
- table2dicts(keys, table)[source]
Converts a 2-D table and a set of keys in a list of dictionaries
- tuples2lists(tuples)[source]
Converts a N-D tuple to a N-D list