The reason it doesn't work is that QPython programs are run from '/' directory which of course is not writable to non-root users. You can check this with the following code run from the console.
import os
print(os.getcwd())
If you go to the ftp
utility in the About menu, you will find a directory path that is being used by QPython3. On my HTC mobile it is:
/storage/emulated/0/com.hipipal.qpyplus
So I changed your example code to:
import os
import sqlite3
RootPath='/storage/emulated/0/com.hipipal.qpyplus'
conn=sqlite3.connect(os.path.join(RootPath,'mydatabase.db'))
and it works fine for me.
I also found that it is necessary to commit changes or they won't be written to the file. That is, end programs with:
conn.commit()
conn.close()