Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support sqlite3 uri filenames #57982

Closed
poq mannequin opened this issue Jan 11, 2012 · 17 comments
Closed

Support sqlite3 uri filenames #57982

poq mannequin opened this issue Jan 11, 2012 · 17 comments
Labels
extension-modules C modules in the Modules dir type-feature A feature request or enhancement

Comments

@poq
Copy link
Mannequin

poq mannequin commented Jan 11, 2012

BPO 13773
Nosy @amauryfa, @pitrou, @merwok, @serhiy-storchaka, @anjos
Files
  • sqlite-uri.patch
  • sqlite-uri.v2.patch
  • sqlite-uri.v3.patch
  • sqlite_open_uri.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2013-02-09.23:07:47.396>
    created_at = <Date 2012-01-11.20:33:18.036>
    labels = ['extension-modules', 'type-feature']
    title = 'Support sqlite3 uri filenames'
    updated_at = <Date 2013-02-10.13:23:52.989>
    user = 'https://bugs.python.org/poq'

    bugs.python.org fields:

    activity = <Date 2013-02-10.13:23:52.989>
    actor = 'serhiy.storchaka'
    assignee = 'none'
    closed = True
    closed_date = <Date 2013-02-09.23:07:47.396>
    closer = 'pitrou'
    components = ['Extension Modules']
    creation = <Date 2012-01-11.20:33:18.036>
    creator = 'poq'
    dependencies = []
    files = ['24205', '24207', '24420', '28982']
    hgrepos = []
    issue_num = 13773
    keywords = ['patch']
    message_count = 17.0
    messages = ['151089', '151090', '151097', '152521', '152549', '152595', '152640', '152672', '170297', '170311', '180025', '181556', '181769', '181770', '181779', '181784', '181801']
    nosy_count = 8.0
    nosy_names = ['ghaering', 'amaury.forgeotdarc', 'pitrou', 'eric.araujo', 'python-dev', 'poq', 'serhiy.storchaka', 'anjos']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue13773'
    versions = ['Python 3.4']

    @poq
    Copy link
    Mannequin Author

    poq mannequin commented Jan 11, 2012

    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.

    @poq poq mannequin added extension-modules C modules in the Modules dir type-feature A feature request or enhancement labels Jan 11, 2012
    @amauryfa
    Copy link
    Member

    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)

    @poq
    Copy link
    Mannequin Author

    poq mannequin commented Jan 11, 2012

    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...

    @merwok
    Copy link
    Member

    merwok commented Feb 3, 2012

    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.

    @poq
    Copy link
    Mannequin Author

    poq mannequin commented Feb 3, 2012

    Can you open a bug report for that?

    Opened bpo-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'.

    @merwok
    Copy link
    Member

    merwok commented Feb 4, 2012

    [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.)

    @poq
    Copy link
    Mannequin Author

    poq mannequin commented Feb 4, 2012

    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. :)

    @merwok
    Copy link
    Member

    merwok commented Feb 5, 2012

    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.

    @anjos
    Copy link
    Mannequin

    anjos mannequin commented Sep 11, 2012

    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.

    @merwok
    Copy link
    Member

    merwok commented Sep 11, 2012

    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.

    @pitrou
    Copy link
    Member

    pitrou commented Jan 15, 2013

    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).

    @pitrou
    Copy link
    Member

    pitrou commented Feb 6, 2013

    Here is an updated patch.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Feb 9, 2013

    New changeset f13bb1e40fbc by Antoine Pitrou in branch 'default':
    Issue bpo-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

    @pitrou
    Copy link
    Member

    pitrou commented Feb 9, 2013

    I've committed the patch, closing.

    @serhiy-storchaka
    Copy link
    Member

    You can use "p" format in PyArg_ParseTuple* for boolean parameters.

    @pitrou
    Copy link
    Member

    pitrou commented Feb 10, 2013

    You can use "p" format in PyArg_ParseTuple* for boolean parameters.

    That's what I used, indeed.

    @serhiy-storchaka
    Copy link
    Member

    Oh, I were blind.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    extension-modules C modules in the Modules dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants