Python's sqlite3 module cannot open the database from a file number, and even using StringIO will not give you the file number (since it does not open the file, it simply emulates a Python file object).
You can use a special file name :memory: to avoid writing the file to disk and then writing it to disk as soon as you are done with it. It also ensures that the file is optimized for size, and you can opt out of writing, for example. indexes if size is really a big problem.
source share