--- a/mytoolkit/mymanager.py Sat Sep 29 12:08:47 2012 +0200
+++ b/mytoolkit/mymanager.py Sat Sep 29 13:53:54 2012 +0200
@@ -2,7 +2,7 @@
#
# MyManager - manage database connections (MySQL version)
#
-# Requires: Python 2.6, MySQLdb
+# Requires: Python 2.6 / 2.7, MySQLdb
#
# Part of pgtoolkit
# http://hg.devl.cz/pgtoolkit
@@ -93,7 +93,7 @@
self.keep_open = keep_open
self.parameters = kw
self.adjust_parameters()
-
+
def adjust_parameters(self):
'''Rename Postgres parameters to proper value for MySQL.'''
m = {'dbname' : 'db', 'password' : 'passwd'}
@@ -166,9 +166,9 @@
def close_conn(self, name='default'):
'''Close all connections of given name.
-
+
Connection credentials are still saved.
-
+
'''
while len(self.conn_pool[name]):
conn = self.conn_pool[name].pop()
@@ -176,9 +176,9 @@
def destroy_conn(self, name='default'):
'''Destroy connection.
-
+
Counterpart of create_conn.
-
+
'''
if not name in self.conn_known:
raise MyManagerError('Connection name "%s" not registered.' % name)
@@ -213,10 +213,10 @@
def put_conn(self, conn, name='default'):
'''Put connection back to pool.
-
+
Name must be same as used for get_conn,
otherwise things become broken.
-
+
'''
self.lock.acquire()
try:
@@ -241,10 +241,10 @@
@contextmanager
def cursor(self, name='default'):
'''Cursor context.
-
+
Uses any connection of name 'name' from pool
and returns cursor for that connection.
-
+
'''
conn = self.get_conn(name)