Package tlib :: Package base :: Module MysqlConnector :: Class MysqlConnector |
[hide private]
[frames] | no frames]

# Class MysqlConnector

source code

    object --+
             |
            MysqlConnector

Connects to MySQL DB, executes queries Autocommit is disabled by default, commit is done with commit function Warnings are turned into exceptions

Instance Methods | [hide private]
__init__(self, config_data, cursor_class=None) Initialize DB connection. | source code
get_autocommit_status(self, var_type=`'``local``'`) returns Autocommit status This is an alias to get_autocommit() | source code
get_autocommit(self, var_type=`'``local``'`) returns Autocommit status | source code
set_autocommit(self, value) returns tuple Autocommit status i.e. | source code
query_select(self, query, *params) Send/execute SELECT queries, returns data from DB :param: str MySQL query :return: tuple with arguments dictionaries, each dictionary is a row of DB i.e. | source code
query_execute(self, query) Sends query to DB. | source code
commit(self) Commits all changes, returns Exception in case of failure | source code
rollback(self) Rolls back all commits, returns exception in case of failure | source code
close_cursor(self) Close cursor. | source code
close_db(self) Close DB connection. | source code
__del__(self) | source code
Inherited from `object`: `__delattr__`, `__format__`, `__getattribute__`, `__hash__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__repr__`, `__setattr__`, `__sizeof__`, `__str__`, `__subclasshook__`

Properties | [hide private]
Inherited from `object`: `__class__`

Method Details | [hide private]

### __init__(self, config_data, cursor_class=None) (Constructor) | source code
Initialize DB connection. Turning warning into exceptions :param cursor_class: Cursor type to use. See MySQLdb for more info :type cursor_class: DictCursor|Cursor|SSCursor|SSDictCursor Overrides: object.__init__

### get_autocommit(self, var_type=`'``local``'`) | source code
returns Autocommit status Returns: bool

### set_autocommit(self, value) | source code
returns tuple Autocommit status i.e. ({'Value': 'ON', 'Variable_name':'autocommit'},) Parameters: `value` (bool)

### query_select(self, query, *params) | source code
Send/execute SELECT queries, returns data from DB :param: str MySQL query :return: tuple with arguments dictionaries, each dictionary is a row of DB i.e. ({row_first}, {row_second}, ... ,{row_last})

### query_execute(self, query) | source code
Sends query to DB. Can be DELETE, UPDATE :param: str query :return: dict {DictCursor}

### close_cursor(self) | source code
Close cursor. Connection to DB is still open, new cursor can be created

### close_db(self) | source code
Close DB connection. All uncommitted changes are lost