コード例 #1
0
def main():
    db = DB('pipeline')
    name = 'worker01'
    statement = '''
        create table pipeline(
            fileid int, 
            clientid int, 
            filename char(255), 
            source char(50), 
            worker char(20), 
            starttime char(20), 
            endtime char(20),
        );
    '''
    db.execute(statement)
    statement = '''
        insert into pipeline values (
            123, 
            23, 
            'abc.txt', 
            'ftp', 
            f{name}, 
            '12:12:12 1:1:1', 
            '13:12:12 1:1:1'
        );
    '''
    while True:
        db = DB('pipeline')
        files = get_files(db, name) 
        print(files)
コード例 #2
0
        union all 
            select 5 as col1, 200 as col2, 'file5.txt' as col3, 'ftp' as col4 
        union all 
            select 6 as col1, 200 as col2, 'file6.txt' as col3, 'ftp' as col4 
        union all 
            select 7 as col1, 200 as col2, 'file7.txt' as col4, 'ftp' as col5 
        union all 
            select 8 as col1, 300 as col2, 'file8.txt' as col3, 'ftp' as col4 
        union all 
            select 9 as col1, 300 as col2, 'file9.txt' as col3, 'ftp' as col4 
        union all 
            select 10 as col1, 300 as col2, 'file10.txt' as col3, 'ftp' col4 
        union all 
            select 11 as col1, 300 as col2, 'file11.txt' as col3, 'ftp' as col4 
        union all 
            select 12 as col1, 300 as col2, 'file12.txt' as col3, 'ftp' as col4
        union all 
            select 13 as col1, 300 as col2, 'file13.txt' as col3, 'ftp' as col4 
        union all 
            select 14 as col1, 300 as col2, 'file14.txt' as col3, 'ftp' as col4 
        union all 
            select 16 as col1, 400 as col2, 'file16.txt' as col3, 'ftp' as col4
        union all 
            select 17 as col1, 500 as col2, 'file17.txt' as col3, 'ftp' as col4;
    '''
    db.execute(statement)
    print('Populated table file_source')
except Exception as e:
    print(e)
db.close_connection()
コード例 #3
0
    statement = '''
        insert into pipeline values (
            123, 
            23, 
            'abc.txt', 
            'ftp', 
            f{name}, 
            '12:12:12 1:1:1', 
            '13:12:12 1:1:1'
        );
    '''
    while True:
        db = DB('pipeline')
        files = get_files(db, name) 
        print(files)

if __name__ == '__main__':
    db = DB('data_source')
    try:
        output = db.execute('''
            select * from data_source;
        ''')
        print(output)
    except Exception as e:
        print(e)

    # main()