Project

General

Profile

« Previous | Next » 

Revision 342

exc.py: Added print_ex()

View differences:

sql.py
136 136
    'PostgreSQL': ('psycopg2', {}),
137 137
}
138 138

  
139
DatabaseErrors_set = set()
140
DatabaseErrors = ()
141

  
142
def _add_module(module):
143
    DatabaseErrors_set.add(module.DatabaseError)
144
    global DatabaseErrors
145
    DatabaseErrors = tuple(DatabaseErrors_set)
146

  
139 147
def connect(db_config):
140 148
    db_config = db_config.copy() # don't modify input!
141
    module, mappings = db_engines[db_config.pop('engine')]
149
    module_name, mappings = db_engines[db_config.pop('engine')]
150
    module = __import__(module_name)
151
    _add_module(module)
142 152
    for orig, new in mappings.iteritems():
143 153
        try: util.rename_key(db_config, orig, new)
144 154
        except KeyError: pass
145
    return __import__(module).connect(**db_config)
155
    return module.connect(**db_config)

Also available in: Unified diff