1717logger = logging .getLogger (__name__ )
1818
1919
20- def conn (host = None , user = None , passwd = None , init_fun = None , reset = False ):
20+ def conn (host = None , user = None , password = None , init_fun = None , reset = False ):
2121 """
2222 Returns a persistent connection object to be shared by multiple modules.
2323 If the connection is not yet established or reset=True, a new connection is set up.
@@ -27,18 +27,20 @@ def conn(host=None, user=None, passwd=None, init_fun=None, reset=False):
2727
2828 :param host: hostname
2929 :param user: mysql user
30- :param passwd : mysql password
30+ :param password : mysql password
3131 :param init_fun: initialization function
32- :param reset: whether the connection should be reseted or not
32+ :param reset: whether the connection should be reset or not
3333 """
3434 if not hasattr (conn , 'connection' ) or reset :
3535 host = host if host is not None else config ['database.host' ]
3636 user = user if user is not None else config ['database.user' ]
37- passwd = passwd if passwd is not None else config ['database.password' ]
38- if passwd is None : # pragma: no cover
39- passwd = getpass (prompt = "Please enter database password: " )
37+ password = password if password is not None else config ['database.password' ]
38+ if user is None : # pragma: no cover
39+ user = input ("Please enter DataJoint username: " )
40+ if password is None : # pragma: no cover
41+ password = getpass (prompt = "Please enter DataJoint password: " )
4042 init_fun = init_fun if init_fun is not None else config ['connection.init_function' ]
41- conn .connection = Connection (host , user , passwd , init_fun )
43+ conn .connection = Connection (host , user , password , init_fun )
4244 return conn .connection
4345
4446
@@ -51,17 +53,17 @@ class Connection:
5153
5254 :param host: host name
5355 :param user: user name
54- :param passwd : password
55- :param init_fun: initialization function
56+ :param password : password
57+ :param init_fun: connection initialization function (SQL)
5658 """
5759
58- def __init__ (self , host , user , passwd , init_fun = None ):
60+ def __init__ (self , host , user , password , init_fun = None ):
5961 if ':' in host :
6062 host , port = host .split (':' )
6163 port = int (port )
6264 else :
6365 port = config ['database.port' ]
64- self .conn_info = dict (host = host , port = port , user = user , passwd = passwd )
66+ self .conn_info = dict (host = host , port = port , user = user , passwd = password )
6567 self .init_fun = init_fun
6668 print ("Connecting {user}@{host}:{port}" .format (** self .conn_info ))
6769 self ._conn = None
0 commit comments