def get_profile(sqshrc="~/.sqshrc", connector='Sybase',
                hostname=None, username=None, password=None):
    """
    get database, username, password from .sqshrc file e.g.
    \set username="user"
    """
    if connector == 'Sybase':
        shost, suser, spass = None, None, None
        _ = lambda x: x.split("=")[-1].translate(None, "\"'").strip()
        sqshrc = op.expanduser(sqshrc)
        if op.exists(sqshrc):
            for row in open(sqshrc):
                row = row.strip()
                if not row.startswith("\\set") or "prompt" in row:
                    continue
                if "password" in row:
                    spass = _(row)
                if "hostname" in row:
                    shost = _(row)
                if "username" in row:
                    suser = _(row)
        else:
            print("[warning] file `{0}` not found".format(sqshrc), file=sys.stderr)

        if suser and spass:
            username, password = suser, spass
        if shost:
            hostname = shost

    dhost, duser, dpass = db_defaults(connector=connector)
    if not password:
        username, password = duser, dpass
    elif not username:
        username = getusername()

    if not hostname:
        hostname = dhost

    return hostname, username, password
def get_profile ( sqshrc = "~/.sqshrc" , connector = 'Sybase' , hostname = None , username = None , password = None ) : if connector == 'Sybase' : shost , suser , spass = None , None , None _ = lambda x : x . split ( "=" ) [ - 1 ] . translate ( None , "\"'" ) . strip ( ) sqshrc = op . expanduser ( sqshrc ) if op . exists ( sqshrc ) : for row in open ( sqshrc ) : row = row . strip ( ) if not row . startswith ( "\\set" ) or "prompt" in row : continue if "password" in row : spass = _ ( row ) if "hostname" in row : shost = _ ( row ) if "username" in row : suser = _ ( row ) else : print ( "[warning] file `{0}` not found" . format ( sqshrc ) , file = sys . stderr ) if suser and spass : username , password = suser , spass if shost : hostname = shost dhost , duser , dpass = db_defaults ( connector = connector ) if not password : username , password = duser , dpass elif not username : username = getusername ( ) if not hostname : hostname = dhost return hostname , username , password
get database, username, password from .sqshrc file e.g.
    \set username="user"