示例#1
0
def create_input_columns(input_columns, new_model_id, session):
    for model_column, datasource_column in input_columns.items():
        create_row(ModelInputColumnModel, {
            "model_id": new_model_id,
            "model_column": model_column,
            "datasource_column": datasource_column
        }, session)
示例#2
0
def update_user(sender_num='+16574457032'):

    conn = db.create_connection("user.db")

    current_count = db.select_rows(conn, sender_num)

    if current_count == 0:
        db.create_row(conn, sender_num, current_count)

    db.insert_rows(conn, sender_num, current_count)

    return current_count
示例#3
0
def create_sql(korean_doc='korean_doc.xlsx'):
    table = files.open_table(filename=korean_doc, sheetname='database(en)')
    sql_rows = list()
    # === переименование нужных таблиц с корейского варианта ===
    for row in range(len(table)):
        if table[row][0] is not None and table[row][1] is None:
            if 'monmakingitem (option)' in table[row][0].lower():
                table[row][0] = 'monmakingitem3'
            elif 'mvp' in table[row][0].lower():
                table[row][0] = 'MVP'
    # === проходит по всем таблицам и получаем для них запросы для обновления базы ===
    skip_one = False
    skip_table = False
    for row in table:
        if skip_one == True: skip_one = False  # пропуск шапки
        elif row[0] is None: pass  # пропуск пустых
        elif row[0] is not None and row[1] is None:  # обновление таблицы
            skip_table = False  # если пропустили предыдущую таблицу
            current_table = row[0]  # пошла новая таблица
            if current_table in dbitems.all_tables: skip_one = True
            else:
                skip_table = True
                print(
                    "\033[31m Внимание\033[0m - пропущена таблица {}!".format(
                        current_table))
        elif skip_table == True:
            pass  # пропуск таблицы
        else:
            sql_rows.append(db.create_row(current_table, row))
    sql_text = '\n'.join(sql_rows)
    return sql_text
示例#4
0
def create_model(json):
    name = json["name"]
    type_name = json["type"]
    datasource_id = json["datasource"]
    input_columns = json["input-columns"]
    type_id = with_session(compose(
        getattr("id"),
        query_type_by_name(type_name)
    ))
    new_model_id = with_session(create_row(ModelModel, {
        "name": name,
        "type_id": type_id,
        "datasource_id": datasource_id
    }))["id"]
    with_session(create_input_columns(input_columns, new_model_id))
    queue_model_creation_task(json)
    return get_model(new_model_id)
示例#5
0
from __future__ import absolute_import
from db import with_session, create_row, row_ids, RecommenderModel
from .get import get_recommender


create_recommender_model = create_row(RecommenderModel)


def create_recommender(json):
    model_id = json["model"]
    default_n = json["default-recommendations"]
    new_recommender_id = with_session(create_recommender_model({"model_id": model_id, "default_n": default_n}))["id"]
    return get_recommender(new_recommender_id)
示例#6
0
from __future__ import absolute_import
from pyramda import curry
from db import \
    DatasourceModel, \
    DatasourceColumnNameModel, \
    create_row, \
    with_session
from .storage import \
    store_csv_file, \
    save_rows_to_csv_file, \
    csv_file_column_names
from log import log


create_datasource = create_row(DatasourceModel)
create_datasource_column_name = create_row(DatasourceColumnNameModel)


def create_datasource_from_csv(csv_file):
    store_csv_file(csv_file)
    name = csv_file.filename
    column_names = csv_file_column_names(name)
    datasource = with_session(create_datasource({
        "name": name
    }))
    ds_id = datasource["id"]
    create_columns = create_datasource_column_names(ds_id, column_names)
    column_names = [column["name"] for column in with_session(create_columns)]
    datasource["column-names"] = column_names
    return datasource
示例#7
0
import sys
sys.path.append('D:/Games/Scripts/module/')
import db, dbitems
import files

table = files.open_table()
# for row in range(len(table)):
#     for col in range(len(table[row])):
#         print(str(table[row][col])+'\t', end='')
#     print('\n')

skip_one = False
for row in table:
    if skip_one == True: skip_one = False  # пропуск шапки
    elif row[0] is None: pass  # пропуск пустых
    elif row[0] in dbitems.all_tables:  # обновление текущей таблицы
        current_table = row[0]
        skip_one = True
    else:
        print(db.create_row(current_table, row))