예제 #1
0
def write_to_sqlite(db_name=None,db_path=None):
    db_path = db_root + datehelper.time_str2()+'.db3'
    print db_path
    con = sqlite3.connect(db_path)
    cur = con.cursor()
    cur.execute('CREATE TABLE foo (o_id INTEGER PRIMARY KEY, fruit VARCHAR(20), veges VARCHAR(30))')
    con.commit()
    cur.execute('INSERT INTO foo (o_id, fruit, veges) VALUES(NULL, "apple", "broccoli")')
    con.commit()
    print cur.lastrowid
    #con.close()
    return db_path
예제 #2
0
def write_to_sqlite(db_name=None, db_path=None):
    db_path = db_root + datehelper.time_str2() + '.db3'
    print db_path
    con = sqlite3.connect(db_path)
    cur = con.cursor()
    cur.execute(
        'CREATE TABLE foo (o_id INTEGER PRIMARY KEY, fruit VARCHAR(20), veges VARCHAR(30))'
    )
    con.commit()
    cur.execute(
        'INSERT INTO foo (o_id, fruit, veges) VALUES(NULL, "apple", "broccoli")'
    )
    con.commit()
    print cur.lastrowid
    #con.close()
    return db_path
예제 #3
0
def write_to_csv(title_list=[], data_list=[], file_name=None, file_path=None):
    """data write to csv file"""
    real_path = ""
    if file_path:
        real_path = file_path
    else:
        real_path = file_root
    if file_name:
        real_path += file_name
    else:
        real_path += datehelper.time_str2() + ".csv"
    csvfile = file(real_path, "wb")
    writer = csv.writer(csvfile)
    writer.writerow(title_list)
    writer.writerows(data_list)
    csvfile.close()
    return real_path
예제 #4
0
def write_to_csv(title_list=[], data_list=[], file_name=None, file_path=None):
    '''data write to csv file'''
    real_path = ''
    if file_path:
        real_path = file_path
    else:
        real_path = file_root
    if file_name:
        real_path += file_name
    else:
        real_path += datehelper.time_str2() + '.csv'
    csvfile = file(real_path, 'wb')
    writer = csv.writer(csvfile)
    writer.writerow(title_list)
    writer.writerows(data_list)
    csvfile.close()
    return real_path