Exemplo n.º 1
0
def up_key(list3, db_file1, sql):
    conn = get_db_conn(db_file1)
    cur = conn.cursor()  # 创建游标
    cur.executemany(sql, list3)  # 执行sql语句
    conn.commit()  # 提交结果
    close_db_conn(cur, conn)
    return cur.rowcount
Exemplo n.º 2
0
def up_key(list3, db_file1):
    sql = '''
    UPDATE Project SET secretKey = ? WHERE projectCode = ?
    '''
    conn = get_db_conn(db_file1)
    cur = conn.cursor()  # 创建游标
    cur.executemany(sql, list3)  # 执行sql语句
    conn.commit()  # 提交结果
    close_db_conn(cur, conn)
    return cur.rowcount
Exemplo n.º 3
0
def up_data(dict, db_file1):
    sql = '''
    UPDATE ls1 SET no1 = ? WHERE appid = 33011220210125012001
    '''
    conn = get_db_conn(db_file1)
    cur = conn.cursor()  # 创建游标
    cur.executemany(sql, dict)  # 执行sql语句
    conn.commit()  # 提交结果
    close_db_conn(cur, conn)
    return cur.rowcount
Exemplo n.º 4
0
def init_db(db_file, sql):
    conn = get_db_conn(db_file)
    cur = conn.cursor()  # 创建游标
    try:
        conn.execute(sql)
        print('1、建表成功/表已创建')
    except:
        print('1、建表失败')
        return False
    conn.commit()  # 提交结果
    close_db_conn(cur, conn)
Exemplo n.º 5
0
def insert_mult_data():
    sql = '''insert into table1 (name, age, address, salary)
        values(?,?,?,?)   -- 元组
        '''
    # 构建一个元组

    conn = get_db_conn(db_file)
    cur = conn.cursor()  # 创建游标
    cur.executemany(sql, socre_list)  # 执行sql语句
    conn.commit()  # 提交结果
    close_db_conn(cur, conn)
    return cur.rowcount
Exemplo n.º 6
0
def insert_mult_data(list3, db_file1):

    # list[i] = tuple(list[i])  # value
    # print((list[i]))
    sql = '''insert into Project5 (
        address,
        areaId,
        builderLicenseNumber,
        buildingArea,
        category,
        categoryName,
        city,
        completeDate,
        contractorCorpNames,
        county,
        govOrgId,
        invest,
        lat,
        lng,
        orgName,
        projectArea,
        projectCode,
        projectId,
        projectName,
        projectStatus,
        projectStatusName,
        province,
        small,
        startDate,
        street,
        time)
        values(
        ?,?,?,?,?,?,?,?,
        ?,?,?,?,?,?,?,?,?,
        ?,?,?,?,?,?,?,?,?
        )   -- 元组
        '''
    # 构建一个元组
    conn = get_db_conn(db_file1)
    cur = conn.cursor()  # 创建游标
    cur.executemany(sql, list3)  # 执行sql语句
    conn.commit()  # 提交结果
    close_db_conn(cur, conn)
    return cur.rowcount
Exemplo n.º 7
0
def init_db():
    # 创建数据表
    sql = '''
        create table ls1
        (
        id integer primary key autoincrement,
        name text,
        appid int,
        no1 int,
        time text,
        is1 int 
        )
    '''

    conn = get_db_conn(db_file)  # 打开或创建数据库文件
    cur = conn.cursor()  # 创建游标
    cur.execute(sql)  # 执行sql语句
    conn.commit()  # 提交结果
    close_db_conn(cur, conn)
Exemplo n.º 8
0
def init_db(db_file1):
    conn = get_db_conn(db_file1)
    cur = conn.cursor()  # 创建游标
    try:
        sql1 = '''
            CREATE TABLE IF NOT EXISTS Project5
            (id integer primary key autoincrement,
        address text,
        areaId int,
        builderLicenseNumber text,
        buildingArea text,
        category text,
        categoryName text,
        city text,
        completeDate text,
        contractorCorpNames text,
        county text,
        govOrgId int,
        invest REAL,
        lat REAL,
        lng REAL,
        orgName text,
        projectArea text,
        projectCode text,
        projectId int,
        projectName text,
        projectStatus text,
        projectStatusName text,
        province text,
        small int,
        startDate text,
        street text,
        secretKey text,
        time text);
        '''
        conn.execute(sql1)
    except:
        print("建表失败")
        return False
    conn.commit()  # 提交结果
    close_db_conn(cur, conn)
Exemplo n.º 9
0
def init_db(db_file1):
    conn = get_db_conn(db_file1)
    cur = conn.cursor()  # 创建游标
    try:
        sql1 = '''
            CREATE TABLE IF NOT EXISTS XSts 
            (id integer primary key autoincrement,
        createTime text,
        myProjectCode text,
        projectId text,
        projectName text,
        pushAppId text,
        pushSecurityKey text,
        time text);
        '''
        conn.execute(sql1)
    except:
        print("建表失败")
        return False
    conn.commit()  # 提交结果
    close_db_conn(cur, conn)
Exemplo n.º 10
0
def insert_mult_data(list3, db_file1):

        # list[i] = tuple(list[i])  # value
        # print((list[i]))
    sql = '''insert into XSts(
        createTime,
        myProjectCode,
        projectId,
        projectName,
        pushAppId,
        pushSecurityKey,
        time)
        values(?,?,?,?,?,?,?)   -- 元组
        '''
    # 构建一个元组
    conn = get_db_conn(db_file1)
    cur = conn.cursor()  # 创建游标
    cur.executemany(sql, list3)  # 执行sql语句
    conn.commit()  # 提交结果
    close_db_conn(cur, conn)
    return cur.rowcount
Exemplo n.º 11
0
def insert_mult_data(list3, db_file1):
    sql = '''insert into Project (
        ProjectID,
        ProName,
        ProjectCategory,
        ProStatus,
        ConsUnitName,
        ShigongUnitName,
        xsProjectCode,
        xsSecretKey,
        xsProjectCodeis,
        hzProjectCodeis,
        time)
        values(?,?,?,?,?,?,?,?,?,?,?)   -- 元组
        '''
    conn = get_db_conn(db_file1)  # 连接数据库
    cur = conn.cursor()  # 创建游标
    cur.executemany(sql, list3)  # 执行sql语句
    conn.commit()  # 提交结果
    close_db_conn(cur, conn)  # 关闭游标及连接
    return cur.rowcount