61 password = source['db-password'] |
61 password = source['db-password'] |
62 else: |
62 else: |
63 password = getpass('password: ') |
63 password = getpass('password: ') |
64 extra_args = source.get('db-extra-arguments') |
64 extra_args = source.get('db-extra-arguments') |
65 extra = extra_args and {'extra_args': extra_args} or {} |
65 extra = extra_args and {'extra_args': extra_args} or {} |
66 return get_connection(driver, dbhost, dbname, user, password=password, |
66 cnx = get_connection(driver, dbhost, dbname, user, password=password, |
67 port=source.get('db-port'), |
67 port=source.get('db-port'), |
68 **extra) |
68 **extra) |
|
69 if not hasattr(cnx, 'logged_user'): # XXX logilab.db compat |
|
70 try: |
|
71 cnx.logged_user = user |
|
72 except AttributeError: |
|
73 # C object, __slots__ |
|
74 from logilab.db import _SimpleConnectionWrapper |
|
75 cnx = _SimpleConnectionWrapper(cnx) |
|
76 cnx.logged_user = user |
|
77 return cnx |
69 |
78 |
70 def system_source_cnx(source, dbms_system_base=False, |
79 def system_source_cnx(source, dbms_system_base=False, |
71 special_privs='CREATE/DROP DATABASE', verbose=True): |
80 special_privs='CREATE/DROP DATABASE', verbose=True): |
72 """shortcut to get a connextion to the instance system database |
81 """shortcut to get a connextion to the instance system database |
73 defined in the given config. If <dbms_system_base> is True, |
82 defined in the given config. If <dbms_system_base> is True, |