Re: Is there a way to yield an error when opening a nonexistent dbfile?

Peng Yu <[email protected]>
Newsgroups gmane.comp.db.sqlite.general
Message-ID <CABrM6w=6e6b1VBSp3_FRauAbPuuzu5N7sSKAc_WxO7aL3YfgDw@mail.gmail.com>
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
[email protected]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.