so if i have something like
CREATE TABLE
IF NOT EXISTS genres (id INTEGER PRIMARY KEY, name TEXT NOT NULL UNIQUE);
CREATE TABLE
IF NOT EXISTS studios (id INTEGER PRIMARY KEY, name TEXT NOT NULL UNIQUE);
CREATE TABLE
IF NOT EXISTS anime_db (
id INTEGER PRIMARY KEY,
source TEXT,
title TEXT,
synonyms TEXT,
english TEXT,
japanese TEXT,
type INTEGER,
status INTEGER,
episode_count INTEGER,
episode_length INTEGER,
date_start TEXT,
date_end TEXT,
image TEXT,
age_rating INTEGER,
genres INTEGER,
studios INTEGER,
score REAL,
popularity INTEGER,
synopsis TEXT,
FOREIGN KEY (genres) REFERENCES genres (id),
FOREIGN KEY (studios) REFERENCES studios (id)
);
can i insert in all of them in one statement?
that thing is that i get the data from an api
@staticmethod
def parse_node(data: dict[str, Any]):
node = data["node"]
return (
node["id"],
'myanimelist',
node["title"],
str(node["alternative_titles"]["synonyms"] or '') or None,
node["alternative_titles"]["en"] or None,
node["alternative_titles"]["ja"] or None,
node["media_type"],
node["status"],
node["num_episodes"],
node["average_episode_duration"],
node.get("start_date", "0000-00-00"),
node.get("end_date", "0000-00-00"),
node.get("main_picture", {}).get("large", None),
node.get("rating", "Unknown"),
str([genre['name'] for genre in node.get('genres', '')] or '') or None,
str([studio['name'] for studio in node.get('studios', '')] or '') or None,
node.get("mean", 0),
node["popularity"],
node["synopsis"] or None,
)