+if os.path.exists(dbfile):
+ os.unlink(dbfile)
+
+with sqlite3.connect(dbfile) as sql:
+ c = sql.cursor()
+
+ c.execute("create table cache (name text not null, system int not null, flags int not null, code text not null, primary key (name, system))")
+ c.execute("create table module (name text not null, flags int not null, code blob not null, primary key (name))")
+
+ for name in [js[0:-3] for js in os.listdir(nodejs) if js.endswith('.js')]:
+ with open(nodejs + '/' + name + '.js', 'r') as file:
+ code = file.read()
+ c.execute("insert into module (name, flags, code) values (?, ?, ?)", [name, 0, buffer(code)])
+