Mercurial > p > roundup > code
comparison roundup/backends/back_mysql.py @ 2693:59ea85d47d34
add dbnamestr argument to connection_dict...
...passed to rdbms_common.connection_dict instead of hard-coded 'db'.
this allows maintenance procedures (db_nuke, db_create, db_exists)
to connect without specifying roundup database name:
these functions must not require existing roundup database.
| author | Alexander Smishlajev <a1s@users.sourceforge.net> |
|---|---|
| date | Sun, 26 Sep 2004 15:16:02 +0000 |
| parents | b3f0b7b9d20d |
| children | ca2ee58c8310 |
comparison
equal
deleted
inserted
replaced
| 2692:f1c9873496f0 | 2693:59ea85d47d34 |
|---|---|
| 37 from roundup.backends import rdbms_common | 37 from roundup.backends import rdbms_common |
| 38 import MySQLdb | 38 import MySQLdb |
| 39 import os, shutil | 39 import os, shutil |
| 40 from MySQLdb.constants import ER | 40 from MySQLdb.constants import ER |
| 41 | 41 |
| 42 def connection_dict(config): | 42 def connection_dict(config, dbnamestr=None): |
| 43 d = rdbms_common.connection_dict(config, 'db') | 43 d = rdbms_common.connection_dict(config, dbnamestr) |
| 44 if d.has_key('password'): | 44 if d.has_key('password'): |
| 45 d['passwd'] = d['password'] | 45 d['passwd'] = d['password'] |
| 46 del d['password'] | 46 del d['password'] |
| 47 return d | 47 return d |
| 48 | 48 |
| 130 hyperdb.Number : lambda x: x, | 130 hyperdb.Number : lambda x: x, |
| 131 hyperdb.Multilink : lambda x: x, # used in journal marshalling | 131 hyperdb.Multilink : lambda x: x, # used in journal marshalling |
| 132 } | 132 } |
| 133 | 133 |
| 134 def sql_open_connection(self): | 134 def sql_open_connection(self): |
| 135 kwargs = connection_dict(self.config) | 135 kwargs = connection_dict(self.config, 'db') |
| 136 self.config.logging.getLogger('hyperdb').info('open database %r'%( | 136 self.config.logging.getLogger('hyperdb').info('open database %r'%( |
| 137 kwargs['db'],)) | 137 kwargs['db'],)) |
| 138 try: | 138 try: |
| 139 conn = MySQLdb.connect(**kwargs) | 139 conn = MySQLdb.connect(**kwargs) |
| 140 except MySQLdb.OperationalError, message: | 140 except MySQLdb.OperationalError, message: |
