Hello,

I need to write a script in SQL to import topics + posts into a phpBB forum.

The issue I have is: How can I reference the last topic ID when adding a post to it, since a post must reference a topic?

FWIW, it's in MariaDB, but maybe there's a generic SQL trick to do this.

Code:
#Create new topic (ie. discussion thread)

INSERT INTO `phpbb_topics` (forum_id,topic_title,topic_poster,topic_time) VALUES ();

#Add first post to topic

#INSERT INTO `phpbb_posts` (topic_id,forum_id,poster_id,post_time,post_username,post_text) VALUES ();

INSERT INTO `phpbb_posts` (SELECT LAST_INSERT_ID(),forum_id,poster_id,post_time,post_username,post_text) VALUES ();
Can it be done in SQL, or should I write it in eg. Python?

Thank you.