Skip to content

Commit 9129b2f

Browse files
committed
Fix %CREATE with WASM
1 parent 392dd97 commit 9129b2f

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/xeus_sqlite_interpreter.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,16 @@ namespace xeus_sqlite
9797
m_db = std::make_unique<SQLite::Database>(m_db_path,
9898
SQLite::OPEN_READWRITE |
9999
SQLite::OPEN_CREATE);
100+
101+
#ifdef XSQL_EMSCRIPTEN_WASM_BUILD
102+
// Force SQlite to write a well formed db to FS
103+
m_db->exec("CREATE TABLE __xeus_sqlite_init (id INTEGER);");
104+
m_db.reset();
105+
m_db = std::make_unique<SQLite::Database>(m_db_path, SQLite::OPEN_READWRITE);
106+
m_db->exec("DROP TABLE __xeus_sqlite_init;");
107+
m_db.reset();
108+
m_db = std::make_unique<SQLite::Database>(m_db_path, SQLite::OPEN_READWRITE);
109+
#endif
100110
}
101111

102112
void interpreter::delete_db()

0 commit comments

Comments
 (0)