35 lines
784 B
Python
35 lines
784 B
Python
import sqlite3
|
|
import os
|
|
|
|
DB_PATH = 'noirflow.db'
|
|
|
|
def get_db_connection():
|
|
conn = sqlite3.connect(DB_PATH)
|
|
conn.row_factory = sqlite3.Row
|
|
return conn
|
|
|
|
def init_db():
|
|
conn = get_db_connection()
|
|
# Table for node instances on the board
|
|
conn.execute('''
|
|
CREATE TABLE IF NOT EXISTS node_instances (
|
|
id TEXT PRIMARY KEY,
|
|
node_type_id TEXT,
|
|
x INTEGER,
|
|
y INTEGER,
|
|
data TEXT
|
|
)
|
|
''')
|
|
# Table for connections between nodes
|
|
conn.execute('''
|
|
CREATE TABLE IF NOT EXISTS connections (
|
|
id TEXT PRIMARY KEY,
|
|
from_node TEXT,
|
|
from_slot TEXT,
|
|
to_node TEXT,
|
|
to_slot TEXT
|
|
)
|
|
''')
|
|
conn.commit()
|
|
conn.close()
|