Exemple #1
0
def get_data_table(table_name):

    result = data_tables.get(table_name, None)
    if result is None:
        result = RDBDataTable(table_name, None)
        data_tables[table_name] = result

    return result
def test_create():

    tbl = RDBDataTable("people")
    print("test_create:tbl =", tbl)
    print("HELLO")
Exemple #3
0
# This dictionary contains columns mappings for nevigating from a source table to a destination table.
# The keys is of the form sourcename_destinationname. The entry is a list of the form
# [[sourcecolumn1, destinationcolumn1], ...
join_columns = {}

# Data structure contains RI constraints. The format is a dictionary with an entry for each schema.
# Within the schema entry, there is a dictionary containing the constraint name, source and target tables
# and key mappings.
ri_constraints = None

data_tables = {}

# TODO This is a bit of a hack and we should clean up.
# We should load information from database or configuration file.
people = RDBDataTable("lahman2017.people", key_columns=['playerID'])
data_tables["lahman2017.people"] = people
batting = RDBDataTable("lahman2017.batting",
                       key_columns=['playerID', 'teamID', 'yearID', 'stint'])
data_tables["lahman2017.batting"] = batting
appearances = RDBDataTable("lahman2017.appearances",
                           key_columns=['playerID', 'teamID', 'yearID'])
data_tables["lahman2017.appearances"] = appearances
#offices = RDBDataTable("classiccars.offices", key_columns=['officeCode'])
#data_tables["classiccars.offices"] = offices


def get_data_table(table_name):

    result = data_tables.get(table_name, None)
    if result is None:
Exemple #4
0
def create_rdb_test():

    tbl = RDBDataTable("people")
    print("create_rdb_test:", tbl)
Exemple #5
0
# This dictionary contains columns mappings for nevigating from a source table to a destination table.
# The keys is of the form sourcename_destinationname. The entry is a list of the form
# [[sourcecolumn1, destinationcolumn1], ...
join_columns = {}

# Data structure contains RI constraints. The format is a dictionary with an entry for each schema.
# Within the schema entry, there is a dictionary containing the constraint name, source and target tables
# and key mappings.
ri_constraints = None

data_tables = {}

# TODO This is a bit of a hack and we should clean up.
# We should load information from database or configuration file.
people = RDBDataTable("lahman2017.people", key_columns=['playerID'])
data_tables["lahman2017.people"] = people
batting = RDBDataTable("lahman2017.batting",
                       key_columns=['playerID', 'yearID', 'teamID', 'stint'])
data_tables["lahman2017.batting"] = batting
appearances = RDBDataTable("lahman2017.appearances",
                           key_columns=['playerID', 'yearID', 'teamID'])
data_tables["lahman2017.appearances"] = appearances
offices = RDBDataTable("classiccars.offices", key_columns=['officeCode'])
data_tables["classiccars.offices"] = offices


def get_data_table(table_name):

    result = data_tables.get(table_name, None)
    if result is None:
Exemple #6
0
def test_create():

    tbl = RDBDataTable('People')
    print('test create: tbl = ', tbl)
# This dictionary contains columns mappings for nevigating from a source table to a destination table.
# The keys is of the form sourcename_destinationname. The entry is a list of the form
# [[sourcecolumn1, destinationcolumn1], ...
join_columns = {}

# Data structure contains RI constraints. The format is a dictionary with an entry for each schema.
# Within the schema entry, there is a dictionary containing the constraint name, source and target tables
# and key mappings.
ri_constraints = None

data_tables = {}

# TODO This is a bit of a hack and we should clean up.
# We should load information from database or configuration file.
people = RDBDataTable("HW1.people", key_columns=['playerID'])
data_tables["HW1.people"] = people
batting = RDBDataTable("HW1.batting",
                       key_columns=['playerID', 'yearID', 'teamID', 'stint'])
data_tables["HW1.batting"] = batting
appearances = RDBDataTable("HW1.appearances",
                           key_columns=['playerID', 'yearID', 'teamID'])
data_tables["HW1.appearances"] = appearances
offices = RDBDataTable("HW1.offices", key_columns=['officeCode'])
data_tables["Hw1.offices"] = offices
fantasy_manager = RDBDataTable("HW1.fantasy_manager", key_columns=['id'])
data_tables["Hw1.fantasy_manager"] = fantasy_manager


def get_data_table(table_name):
Exemple #8
0
def test_create():
    tbl = RDBDataTable("people")
    print("test_create:tbl=", tbl)
    print('trying it again')
Exemple #9
0
def create_fantasy_manager():
    tbl = RDBDataTable("people", key_columns="cat")
    r=tbl.insert({"playerID":"aaa1", "birthYear":"1943","birthMonth":"2"})
    print('create_fantasy_manager returned: ', tbl)
Exemple #10
0
def create_rdb_test():
    tbl=RDBDataTable("people",key_columns="cat")
    print("'create_rdb test", tbl)
# This dictionary contains columns mappings for nevigating from a source table to a destination table.
# The keys is of the form sourcename_destinationname. The entry is a list of the form
# [[sourcecolumn1, destinationcolumn1], ...
join_columns = {}

# Data structure contains RI constraints. The format is a dictionary with an entry for each schema.
# Within the schema entry, there is a dictionary containing the constraint name, source and target tables
# and key mappings.
ri_constraints = None

data_tables = {}


# TODO This is a bit of a hack and we should clean up.
# We should load information from database or configuration file.
people = RDBDataTable("lahman2017.people", key_columns=['playerID'])
data_tables["lahman2017.people"] = people
batting = RDBDataTable("lahman2017.batting", key_columns=['playerID', 'teamID', 'yearID', 'stint'])
data_tables["lahman2017.batting"] = batting
appearances = RDBDataTable("lahman2017.appearances", key_columns=['playerID', 'teamID', 'yearID'])
data_tables["lahman2017.appearances"] = appearances
offices = RDBDataTable("classiccars.offices", key_columns=['officeCode'])
data_tables["classiccars.offices"] = offices
fantasy_manager = RDBDataTable("classiccars.fantasy_manager", key_columns=['id'])
data_tables["classiccars.fantasy_manager"] = fantasy_manager
fantasy_team = RDBDataTable("classiccars.fantasy_team", key_columns=['team_id'])
data_tables["classiccars.fantasy_team"] = fantasy_team


def get_data_table(table_name):
from aeneid.dbservices.RDBDataTable import RDBDataTable
from tabulate import tabulate

import pymysql
pymysql.install_as_MySQLdb()

data_tables = {}

cnx = pymysql.connect(host="localhost",
                      database="HW1",
                      user="******",
                      password="******",
                      charset='utf8mb4',
                      cursorclass=pymysql.cursors.DictCursor)

fantasy_manager = RDBDataTable("HW1.fantasy_manager", key_columns=['id'])
data_tables["Hw1.fantasy_manager"] = fantasy_manager


def test_api_1():

    r = requests.get("http://127.0.0.1:5000")
    result = r.text

    print("First REST API returned", r.text)


## Get
def test_json():

    params = {"id": "ok1", "fields": "last_name, first_name, email"}