Beispiel #1
0
def delete_by_key_test():

    connection = SQLHelper.get_default_connection()

    table_name = "lahman2019raw.people"

    rdb_table = RDBDataTable(table_name, ['playerID'], connection)

    result = rdb_table.delete_by_key(['abbotgl01'])

    if result[0] is not None:
        print("%d rows deleted" % result[0])
    else:
        print("None.")
Beispiel #2
0
def find_by_primary_key_test():

    connection = SQLHelper.get_default_connection()

    table_name = "lahman2019raw.people"

    rdb_table = RDBDataTable(table_name, ['playerID'], connection)

    result = rdb_table.find_by_primary_key(
        ['aardsda01'], ['playerID', 'birthYear', 'birthMonth', 'birthDay'])

    if result[1] is not None:
        print(json.dumps(result[1], indent=2))
    else:
        print("None.")
Beispiel #3
0
def delete_by_template_test():

    connection = SQLHelper.get_default_connection()

    table_name = "lahman2019raw.people"

    rdb_table = RDBDataTable(table_name, ['playerID'], connection)

    template = {"birthCity": "Zanesville"}

    result = rdb_table.delete_by_template(template)

    if result[0] is not None:
        print("%d rows deleted" % result[0])
    else:
        print("None.")
Beispiel #4
0
def find_by_template_test():

    connection = SQLHelper.get_default_connection()

    table_name = "lahman2019raw.people"

    rdb_table = RDBDataTable(table_name, ['playerID'], connection)

    template = {"birthCity": "La Guaira"}

    result = rdb_table.find_by_template(
        template, ['playerID', 'birthYear', 'birthMonth', 'birthDay'])

    if result[1] is not None:
        print(json.dumps(result, indent=2))
    else:
        print("None.")
Beispiel #5
0
def update_by_key_test():

    connection = SQLHelper.get_default_connection()

    table_name = "lahman2019raw.batting"

    rdb_table = RDBDataTable(table_name,
                             ['playerID', 'yearID', 'stint', 'teamID'],
                             connection)

    result = rdb_table.update_by_key(["aardsda01", "2010", "1", "SEA"], {
        "teamID": "ATL",
        "AB": "11"
    })

    if result[1] is not None:
        print("%d rows updated" % result[0])
        print(json.dumps(result[0], indent=2))
    else:
        print("None.")
Beispiel #6
0
def insert():

    connection = SQLHelper.get_default_connection()

    table_name = "lahman2019raw.batting"

    rdb_table = RDBDataTable(table_name,
                             ['playerID', 'yearID', 'stint', 'teamID'],
                             connection)

    result = rdb_table.insert({
        "playerID": "test1",
        "yearID": "test",
        "stint": 1,
        "teamID": "test"
    })

    if result[0] is not None:
        print("%d rows inserted" % result[0])
    else:
        print("None.")
Beispiel #7
0
def update_by_template():

    connection = SQLHelper.get_default_connection()

    table_name = "lahman2019raw.batting"

    rdb_table = RDBDataTable(table_name,
                             ['playerID', 'yearID', 'stint', 'teamID'],
                             connection)

    template = {"yearID": "1956"}

    result = rdb_table.update_by_template(template, {
        "teamID": "ATL",
        "AB": "11"
    })

    if result[0] is not None:
        print("%d rows updated" % result[0])
    else:
        print("None.")