smbinterp/gmsh/02_merge_to_sqlite.py

27 lines
708 B
Python

import sys
import numpy as np
import sqlite3
from optparse import OptionParser
if __name__ == '__main__':
parser = OptionParser(usage = "usage: %s <input text file> <output db file>")
(options, args) = parser.parse_args()
if len(args) != 2:
parser.print_usage()
sys.exit(1)
data_file_name, sql_file_name = args
data = np.loadtxt(data_file_name)
con = sqlite3.connect(sql_file_name)
cur = con.cursor()
cur.execute('DROP TABLE IF EXISTS results')
cur.execute('CREATE TABLE results (res INTEGER, ord INTEGER, ep INTEGER, final FLOAT, exact FLOAT, time FLOAT)')
cur.executemany("insert into results values(?,?,?,?,?,?)", data)
con.commit()
cur.close()
con.close()