What is the recommended way to do so in python?

I see the following two ways.

```
db = sqlite3.connect('file:/path/to/database?mode=ro', uri=True)

fd = os.open(filename, os.O_RDONLY)
c = sqlite3.connect('/dev/fd/%d' % fd)
os.close(fd)
```

https://stackoverflow.com/questions/10205744/opening-sqlite3-database-from-python-in-read-only-mode

But can the first have problems when the filename is actually
something like 'file:database?mode=ro'?

For my applications, I only unix like platform. So the second way may be better?

Any other better solutiosn with the python sqlite3 library?

The stackoverflow link also mentions APSW. It seems that it is quite
updated. Is this a good replacement for the python sqlite3 module in
general?

Thanks.

> $ sqlite3 -readonly testx.db
> SQLite version 3.31.1 2020-01-27 19:55:54
> Enter ".help" for usage hints.
> sqlite> .tables
> Error: unable to open database "testx.db": unable to open database file

-- 
Regards,
Peng
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to