This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Unsupported provider

classification
Title: Support sqlite3 uri filenames
Type: enhancement Stage: resolved
Components: Extension Modules Versions: Python 3.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: amaury.forgeotdarc, anjos, eric.araujo, ghaering, pitrou, poq, python-dev, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2012-01-11 20:33 by poq, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
sqlite-uri.patch poq, 2012-01-11 20:33 review
sqlite-uri.v2.patch poq, 2012-01-11 22:44 review
sqlite-uri.v3.patch poq, 2012-02-04 18:51 review
sqlite_open_uri.patch pitrou, 2013-02-06 18:35
Messages (17)
msg151089 - (view) Author: (poq) Date: 2012-01-11 20:33
URIs are an extensible way to pass options to SQLite. See:
http://www.sqlite.org/uri.html

Patch adds a keyword argument "uri" to sqlite3.connect which causes the filename to be parsed as a URI if set to True.
msg151090 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2012-01-11 21:07
Hi, I will let others discuss the feature itself, here are already some comments about your patch:

- In module_connect(), the ability to pass "factory" as a positional argument is broken, please restore the previous code; I'm afraid there is no better implementation, even if it's a copy of connection.__init__.
- I suggest to allow "uri" in all builds, and fail only when it's True on a non supported platform.
- In general, try to wrap C code in 80 columns (except for the ".. function::" directive in .rst files)
- IIRC a correct URI is file:///path/to/file but sqlite probably allows file:/path/to/file as well.
- The test function should use "from test.support import TESTFN" to get a temporary file name (but I agree that sqlite tests don't seem to follow Python standards)
msg151097 - (view) Author: (poq) Date: 2012-01-11 22:44
Thanks for your comments. You're right, I didn't consider positional arguments. Here's a patch that addresses your comments.

Should I also rewrap modified lines that were already much too long?

I also noticed & fixed an unrelated typo in Lib/sqlite3/test/hooks.py...
msg152521 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2012-02-03 14:45
> Should I also rewrap modified lines that were already much too long?
Please don’t, it would make the diff harder to read.

> I also noticed & fixed an unrelated typo in Lib/sqlite3/test/hooks.py...
Can you open a bug report for that?

I think the doc could link to the sqlite.org doc about URIs.
msg152549 - (view) Author: (poq) Date: 2012-02-03 18:54
> Can you open a bug report for that?

Opened #13934.

> I think the doc could link to the sqlite.org doc about URIs.

I considered this, but the rest of the sqlite3 module documentation doesn't link to the sqlite.org doc pages either. There is only a link to http://www.sqlite.org under 'See also'.
msg152595 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2012-02-04 07:18
[Amaury]
> The test function should use "from test.support import TESTFN" to get
> a temporary file name
I believe that TESTFN predates tempfile (and the tempfile helpers in regrtest and test.support) and is now seen as an ugly relic (at least by me :)

[poq]
>> I think the doc could link to the sqlite.org doc about URIs.
> I considered this, but the rest of the sqlite3 module documentation doesn't link to the
> sqlite.org doc pages either.
Well, users need a way to find the list of allowed options.  The Python docs should either list them (there aren’t much; pro: all the info is here, con: maintenance) or link to them.

By the way, do you want to give us your full name so that we can credit you?  (And on a related subject, I don’t know if this small patch requires a contributor agreement.)
msg152640 - (view) Author: (poq) Date: 2012-02-04 18:51
> The Python docs should either list them (there aren’t much; pro: all the info is here, con: maintenance) or link to them.

They've already added a new option ('psow') since I opened this report, so linking is probably more future-proof.

I've added an updated patch which adds a link. I've also changed the exception when URIs are not supported to sqlite3.NotSupportedError.

> By the way, do you want to give us your full name so that we can credit you?

I prefer anonymity. :)
msg152672 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2012-02-05 10:15
> I've added an updated patch which adds a link. I've also changed the exception when URIs
> are not supported to sqlite3.NotSupportedError.
Sounds good.  Note to the person who will commit: :const:`True` should be marked up as ``True.``

> I prefer anonymity. :)
OK.  I’m still not sure if a contributor agreement is needed for this patch.
msg170297 - (view) Author: André Anjos (anjos) Date: 2012-09-11 12:13
A question concerning this patch: is this going to be applied only to 3.3 or to 2.7 as well? Python-2.7.x also does not have this functionality which would be interesting to get.
msg170311 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2012-09-11 15:02
2.7 and 3.2 are stable versions which only get bug fixes.  3.3 is in release candidate stage, so this new feature can only go into 3.4.  See the devguide and PEPs for more info about the process we follow.
msg180025 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2013-01-15 15:59
This would definitely be useful. I would have liked to have this feature today.
poq, could you sign a contributor agreement?
See http://www.python.org/psf/contrib/
Also, it's better if you can use a real name (or at least a well-known pseudonym).
msg181556 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2013-02-06 18:35
Here is an updated patch.
msg181769 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-02-09 23:06
New changeset f13bb1e40fbc by Antoine Pitrou in branch 'default':
Issue #13773: sqlite3.connect() gets a new `uri` parameter to pass the filename as a URI, allowing to pass custom options.
http://hg.python.org/cpython/rev/f13bb1e40fbc
msg181770 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2013-02-09 23:07
I've committed the patch, closing.
msg181779 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-02-10 09:08
You can use "p" format in PyArg_ParseTuple* for boolean parameters.
msg181784 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2013-02-10 11:00
> You can use "p" format in PyArg_ParseTuple* for boolean parameters.

That's what I used, indeed.
msg181801 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-02-10 13:23
Oh, I were blind.
History
Date User Action Args
2022-04-11 14:57:25adminsetgithub: 57982
2013-02-10 13:23:53serhiy.storchakasetmessages: + msg181801
2013-02-10 11:00:34pitrousetmessages: + msg181784
2013-02-10 09:08:11serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg181779
2013-02-09 23:07:47pitrousetstatus: open -> closed
messages: + msg181770

assignee: ghaering ->
resolution: fixed
stage: patch review -> resolved
2013-02-09 23:06:56python-devsetnosy: + python-dev
messages: + msg181769
2013-02-06 18:35:55pitrousetfiles: + sqlite_open_uri.patch

messages: + msg181556
2013-01-15 15:59:29pitrousetmessages: + msg180025
2013-01-15 15:57:32pitrousetnosy: + pitrou
2012-09-11 15:02:41eric.araujosetmessages: + msg170311
versions: + Python 3.4, - Python 3.3
2012-09-11 12:13:49anjossetnosy: + anjos
messages: + msg170297
2012-02-05 10:15:05eric.araujosetmessages: + msg152672
2012-02-04 18:51:50poqsetfiles: + sqlite-uri.v3.patch

messages: + msg152640
2012-02-04 07:18:08eric.araujosetmessages: + msg152595
2012-02-03 18:54:47poqsetmessages: + msg152549
2012-02-03 14:45:18eric.araujosetmessages: + msg152521
2012-01-14 03:57:45eric.araujosetassignee: ghaering

nosy: + eric.araujo, ghaering
2012-01-11 22:44:08poqsetfiles: + sqlite-uri.v2.patch

messages: + msg151097
2012-01-11 21:07:34amaury.forgeotdarcsetnosy: + amaury.forgeotdarc

messages: + msg151090
stage: patch review
2012-01-11 20:33:18poqcreate