def mysql_connect():
    conn = comic_hentai_data_source.get_conn()
    cursor = conn.cursor()
    # 得到当前数据库中的所有表
    cursor.execute(
        "SELECT DISTINCT table_name FROM information_schema.columns WHERE table_schema = 'jxt' ORDER BY table_schema,table_name"
    )
    tables = cursor.fetchall()
    print(tables)
    for table in tables:
        table = table[0]
        if table == 'TestComic' or table == "TestUser":
            continue
        cursor.execute(
            "SELECT column_name,data_type,is_nullable,column_comment FROM information_schema.columns WHERE table_name = '"
            + table + "' ORDER BY table_schema,table_name", )
        values = cursor.fetchall()
        columns = []
        for column in values:
            if not (column[0] == 'id' or column[0] == 'created'
                    or column[0] == 'updated' or column[0] == 'isDeleted'
                    or column[0] == 'status'):
                columns.append(column)
        print(columns)
        initAll(table, columns)
    cursor.close()
    conn.close()
def get_comic():
    conn = comic_hentai_data_source.get_conn()
    find_comic_simple_info = "select id, title from Comic"
    cursor = conn.cursor()
    cursor.execute(find_comic_simple_info)
    result = cursor.fetchall()
    operator = "curl -XPUT "

    for r in result:
        id = str(r[0])
        title = str(r[1])
        title = title.replace("'", "&#39")
        data = json.dumps({"id": id, "title": title})
        url = r"'http://db.hope6537.com:9200/comichentai/comic/" + id + r"'"
        tmp = operator + url + " -d \'" + data + '\''
        print(tmp)
        commands.getstatusoutput(tmp)
def get_comic():
    conn = comic_hentai_data_source.get_conn()
    find_comic_simple_info = "select id, title from Comic"
    cursor = conn.cursor()
    cursor.execute(find_comic_simple_info)
    result = cursor.fetchall()
    operator = "curl -XPUT "

    for r in result:
        id = str(r[0])
        title = str(r[1])
        title = title.replace("'", "&#39")
        data = json.dumps({
            "id": id,
            "title": title
        })
        url = r"'http://db.hope6537.com:9200/comichentai/comic/" + id + r"'"
        tmp = operator + url + " -d \'" + data + '\''
        print(tmp)
        commands.getstatusoutput(tmp)
def mysql_connect():
    conn = comic_hentai_data_source.get_conn()
    cursor = conn.cursor()
    # 得到当前数据库中的所有表
    cursor.execute(
            "select distinct table_name from information_schema.columns where table_schema = 'ComicHentai' order by table_schema,table_name")
    tables = cursor.fetchall()
    print(tables)
    for table in tables:
        table = table[0]
        if table == 'TestComic' or table == "TestUser":
            continue
        cursor.execute(
                "select column_name,data_type,is_nullable,column_comment from information_schema.columns where table_name = '" + table + "' order by table_schema,table_name", )
        values = cursor.fetchall()
        columns = []
        for column in values:
            if not (column[0] == 'id' or column[0] == 'created' or column[0] == 'updated' or column[0] == 'isDeleted' or
                            column[0] == 'status'):
                columns.append(column)
        print(columns)
        initAll(table, columns)
    cursor.close()
    conn.close()