Ejemplo n.º 1
0
def get_rdb_table(table_name, db_name, key_columns=None, connect_info=None):
    """

    :param table_name: Name of the database table.
    :param db_name: Schema/database name.
    :param key_columns: This is a trap. Just use None.
    :param connect_info: You can specify if you have some special connection, but it is
        OK to just use the default connection.
    :return:
    """
    global _db_tables

    # We use the fully qualified table name as the key into the cache, e.g. lahman2019clean.people.
    key = db_name + "." + table_name

    # Have we already created and cache the data table?
    result = _db_tables.get(key, None)

    # We have not yet accessed this table.
    if result is None:

        # Make an RDBDataTable for this database table.
        result = RDBDataTable.RDBDataTable(table_name, db_name, key_columns,
                                           connect_info)

        # Add to the cache.
        _db_tables[key] = result

    return result
Ejemplo n.º 2
0
def t_get_keys():
    db = rdb.RDBDataTable(table_name="appearances",
                          db_name="lahman2019clean",
                          connect_info=connect_info)
    print(db.get_primary_key_columns())


#t_get_db
#t_get_tables("lahman2019clean")
#t_row_counts()
#t_get_keys()
Ejemplo n.º 3
0
def t4():
    print(
        "########################## Test_get_primary_key_columns ##########################"
    )
    connect_info = {
        "host": "127.0.0.1:3306",
        "user": "******",
        "password": "******"
    }
    db = rdb.RDBDataTable("appearances",
                          "lahman2019clean",
                          connect_info=connect_info)
    db.get_primary_key_columns()
    print(
        "########################## Test_get_primary_key_columns ##########################"
    )
Ejemplo n.º 4
0
def t3():
    print(
        "########################## Test_get_row_count ##########################"
    )
    connect_info = {
        "host": "127.0.0.1:3306",
        "user": "******",
        "password": "******"
    }
    db = rdb.RDBDataTable("People",
                          "lahman2019clean",
                          connect_info=connect_info)
    d = db.get_row_count()
    print(f"t3 result ={d}")
    print(
        "########################## Test_get_row_count ##########################"
    )
Ejemplo n.º 5
0
def t_row_counts():
    db = rdb.RDBDataTable(table_name="people",
                          db_name="lahman2019clean",
                          connect_info=connect_info)
    print(db.get_row_count())
Ejemplo n.º 6
0
def get_tables(dbname):
    return RDBDataTable.RDBDataTable().get_tables(dbname)
Ejemplo n.º 7
0
def get_databases():
    """

    :return: A list of databases/schema at this endpoint.
    """
    return RDBDataTable.RDBDataTable().get_databases()