예제 #1
0
def GetUser():
    """
    Get your user name from the .netrc file

    Parameters
    ----------
    None

    Returns
    -------
    username (str)

    """
    user, pwd = _dbfunctions.retrieve_login(_dbfunctions.db_specs.db_host)
    return user
예제 #2
0
def GetUser():
    """
    Get your user name from the .netrc file

    Parameters
    ----------
    None

    Returns
    -------
    username (str)

    """
    user, pwd = _dbfunctions.retrieve_login(_dbfunctions.db_specs.db_host)
    return user
예제 #3
0
def PrintUsage(user=None):
    """
    Print a summary of a user's DB usage.
    Each line prints a table, and its GB usage.
    The last line prints the total usage

    Parameters
    ----------
    user (str)
        The username whose quota you want to return. None means use your personal username (read from the .netrc file).

    Returns
    -------
    None

    """
    if user is None:
        user, pwd = _dbfunctions.retrieve_login(_dbfunctions.db_specs.db_host)

    tables = GetTableNames(user=user.upper())
    _add(tables, user=user.upper())
예제 #4
0
def PrintUsage(user=None):
    """
    Print a summary of a user's DB usage.
    Each line prints a table, and its GB usage.
    The last line prints the total usage

    Parameters
    ----------
    user (str)
        The username whose quota you want to return. None means use your personal username (read from the .netrc file).

    Returns
    -------
    None

    """
    if user is None:
        user, pwd = _dbfunctions.retrieve_login(_dbfunctions.db_specs.db_host)

    tables = GetTableNames(user=user.upper())
    _add(tables, user=user.upper())
예제 #5
0
def GetQuota(user=None):
    """
    Get a user's DB quota (in GB).

    Parameters
    ----------
    user (str)
        The username whose quota you want to return. None means use your personal username (read from the .netrc file).

    Returns
    -------
    quota (float)
        The user's quota in GB.

    """
    if user is None:
        user, pwd = _dbfunctions.retrieve_login(_dbfunctions.db_specs.db_host)

    cur = _desdb.connect()
    q = "SELECT USERNAME, TABLESPACE_NAME, MAX_BYTES from DBA_TS_QUOTAS WHERE USERNAME='******'" % (user.upper())
    all = cur.quick(q, array=True)
    return all["max_bytes"][0] / _np.power(1024.0, 3)
예제 #6
0
def TotalUsage(user=None):
    """
    Find total DB usage for the user.

    Parameters
    ----------
    user (str)
        The username whose usage you want to return. None means use your personal username (read from the .netrc file).

    Returns
    -------
    usage (float)
        Usage in GB

    """

    if user is None:
        user, pwd = _dbfunctions.retrieve_login(_dbfunctions.db_specs.db_host)

    cur = _desdb.connect()
    return cur.quick("""SELECT SUM(bytes) as b from dba_extents where owner='%s'""" % (user.upper()), array=True)["b"][
        0
    ] / _np.power(1024.0, 3)
예제 #7
0
def GetQuota(user=None):
    """
    Get a user's DB quota (in GB).

    Parameters
    ----------
    user (str)
        The username whose quota you want to return. None means use your personal username (read from the .netrc file).

    Returns
    -------
    quota (float)
        The user's quota in GB.

    """
    if user is None:
        user, pwd = _dbfunctions.retrieve_login(_dbfunctions.db_specs.db_host)

    cur = _desdb.connect()
    q = "SELECT USERNAME, TABLESPACE_NAME, MAX_BYTES from DBA_TS_QUOTAS WHERE USERNAME='******'" % (
        user.upper())
    all = cur.quick(q, array=True)
    return all['max_bytes'][0] / _np.power(1024., 3)
예제 #8
0
def GetTableNames(user=None):
    """
    Get all of a user's tables from the DB.

    Parameters
    ----------
    user (str)
        The username whose tables you want to return. None means use your personal username (read from the .netrc file).

    Returns
    -------
    tables (list)
        List of the table's owned by the specified user

    """
    if user is None:
        user, pwd = _dbfunctions.retrieve_login(_dbfunctions.db_specs.db_host)

    names = _get_table_names()
    tables = []
    for name in names:
        if name[0].find(user.upper()) != -1:
            tables.append(name[1])
    return tables
예제 #9
0
def GetTableNames(user=None):
    """
    Get all of a user's tables from the DB.

    Parameters
    ----------
    user (str)
        The username whose tables you want to return. None means use your personal username (read from the .netrc file).

    Returns
    -------
    tables (list)
        List of the table's owned by the specified user

    """
    if user is None:
        user, pwd = _dbfunctions.retrieve_login(_dbfunctions.db_specs.db_host)

    names = _get_table_names()
    tables = []
    for name in names:
        if name[0].find(user.upper()) != -1:
            tables.append(name[1])
    return tables
예제 #10
0
def TotalUsage(user=None):
    """
    Find total DB usage for the user.

    Parameters
    ----------
    user (str)
        The username whose usage you want to return. None means use your personal username (read from the .netrc file).

    Returns
    -------
    usage (float)
        Usage in GB

    """

    if user is None:
        user, pwd = _dbfunctions.retrieve_login(_dbfunctions.db_specs.db_host)

    cur = _desdb.connect()
    return cur.quick(
        """SELECT SUM(bytes) as b from dba_extents where owner='%s'""" %
        (user.upper()),
        array=True)['b'][0] / _np.power(1024.0, 3)