Files
Forge-Engine/screens/flow/add_flow_node.py
T
williamandwilliam 3f4ebc4527
Build and deploy / build-and-push (push) Successful in 17s
Build and deploy / deploy (push) Successful in 10s
first commit
2026-08-21 16:23:49 +02:00

22 lines
739 B
Python

import db
from .ensure_flow_schema import ensure_flow_schema
from .constants import FLOW_NODE_FIELDS
def add_flow_node(slug, screen_id, node_type, x=40, y=40, **fields):
ensure_flow_schema(slug)
cols = ["screen_id", "node_type", "x", "y"]
vals = [screen_id, node_type, x, y]
for k, v in fields.items():
if k in FLOW_NODE_FIELDS and v not in (None, ""):
cols.append(k)
vals.append(v)
placeholders = ", ".join("?" for _ in cols)
conn = db.connect(slug)
conn.execute(f"INSERT INTO _flow_nodes ({', '.join(cols)}) VALUES ({placeholders})", vals)
node_id = conn.execute("SELECT last_insert_rowid() AS id").fetchone()["id"]
conn.commit()
conn.close()
return node_id