-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimport_data.py
31 lines (25 loc) · 1.24 KB
/
import_data.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import create_tables
import sqlite3
from pathlib import Path
def read_file(filename:str)-> list:
path = Path(filename)
if not path.is_absolute():
path=path.resolve()
print(path)
with open(path,'r') as input:
lines = [tuple(line.rstrip().split()) for line in input]
return lines
def delete_all_from_simulations(conn)->bool:
if conn == None:
print("No valid connection")
return False
cur = conn.cursor()
cur.execute("delete from simulations;")
conn.commit()
return True
if __name__=="__main__":
lines = read_file('slurmjoborder.config')
#print(lines)
conn = create_tables.create_connection('sqlite_test.db')
delete_all_from_simulations(conn)
create_tables.insert_into_simulations(conn,lines)