Got closer with the temptables stuff, it turns out the create_database function isn't called at all, instead PDO itself handles creating the database based on the DSN. Still not sure where to create the sqlite3_pdo_moodle_temptables object though. Whatever I do it seems to be null by the time it gets used.
General developer forum
Databases: SQLite support
This discussion has been locked so you can no longer reply to it.