def connection(): credentials = util.dbcredentials() return MySQLdb.connect(host = credentials["host"], # your host, usually localhost user = credentials["user"], # your username passwd = credentials["password"], # your password db = "passwords", cursorclass = MySQLdb.cursors.SSDictCursor) # stores result in the server. records as dict
def connectToDb(): '''Contains the connection string to the database, and returns the connection object.''' cred = util.dbcredentials() return oursql.connect(host=cred["host"], user=cred["user"], passwd=cred["password"], db='passwords', raise_on_warnings=False, charset='utf8', use_unicode=True, port=int(cred["port"]))