GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Enhance sqlite3 to avoid implicit creation? · Issue #90560 · python/cpython

Enhance sqlite3 to avoid implicit creation? #90560

New issue
Copy link
New issue
Copy link
Closed
Closed
Enhance sqlite3 to avoid implicit creation?#90560
Copy link
Labels
3.11only security fixesonly security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-sqlite3type-featureA feature request or enhancementA feature request or enhancement

Description

@nedbat
nedbat
opened on Jan 16, 2022
Issue body actions
BPO 46402
Nosy @ericvsmith, @nedbat, @zware, @miss-islington, @erlend-aasland
PRs
  • bpo-46402: Promote SQLite URI tricks in sqlite3 docs #30660
  • [3.10] bpo-46402: Promote SQLite URI tricks in sqlite3 docs (GH-30660) #30661
  • [3.9] bpo-46402: Promote SQLite URI tricks in sqlite3 docs (GH-30660) #30662
  • [3.10] bpo-46402: Promote SQLite URI tricks in sqlite3 docs (GH-30660) #30671
  • [3.9] bpo-46402: Promote SQLite URI tricks in sqlite3 docs (GH-30660) #30672
  • 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 2022-01-18.22:15:01.743>
    created_at = <Date 2022-01-16.17:42:31.926>
    labels = ['type-feature', 'library', '3.11']
    title = 'Enhance sqlite3 to avoid implicit creation?'
    updated_at = <Date 2022-01-18.22:15:01.742>
    user = 'https://github.com/nedbat'

    bugs.python.org fields:

    activity = <Date 2022-01-18.22:15:01.742>
    actor = 'erlendaasland'
    assignee = 'none'
    closed = True
    closed_date = <Date 2022-01-18.22:15:01.743>
    closer = 'erlendaasland'
    components = ['Library (Lib)']
    creation = <Date 2022-01-16.17:42:31.926>
    creator = 'nedbat'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 46402
    keywords = ['patch']
    message_count = 15.0
    messages = ['410704', '410724', '410779', '410780', '410781', '410783', '410790', '410793', '410851', '410857', '410892', '410895', '410902', '410903', '410906']
    nosy_count = 5.0
    nosy_names = ['eric.smith', 'nedbat', 'zach.ware', 'miss-islington', 'erlendaasland']
    pr_nums = ['30660', '30661', '30662', '30671', '30672']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue46402'
    versions = ['Python 3.11']

    Activity

    1. nedbat commented on Jan 16, 2022

      @nedbat
      nedbat
      on Jan 16, 2022
      MemberAuthor
      More actions

      The sqlite3 library implicitly creates the database if the requested file doesn't exist. I would like to be able to avoid that implicit creation. (Actually, it would be enough to know whether I had created the database, but the underlying SQLite library doesn't seem to indicate that.)

      The C code currently hard-codes the SQLite flag to create the database if it doesn't exist:

          rc = sqlite3_open_v2(database, &db,
                               SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE |
                               (uri ? SQLITE_OPEN_URI : 0), NULL);

      Could we make this an option, so the Python code could avoid implicit creation?

    2. nedbat
      added
      stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
      on Jan 16, 2022
    3. zware
      added
      3.11only security fixesonly security fixes
      type-featureA feature request or enhancementA feature request or enhancement
      on Jan 16, 2022
    4. ericvsmith commented on Jan 16, 2022

      @ericvsmith
      ericvsmith
      on Jan 16, 2022
      Member
      More actions

      I agree that would be a useful option.

    5. erlend-aasland commented on Jan 17, 2022

      @erlend-aasland
      erlend-aasland
      on Jan 17, 2022
      Contributor
      More actions

      FYI, you can already do this using the URI option:

          cx = sqlite3.connect("file:test.db?mode=rw", uri=True)
    6. erlend-aasland commented on Jan 17, 2022

      @erlend-aasland
      erlend-aasland
      on Jan 17, 2022
      Contributor
      More actions

      See also bpo-24887.

    7. erlend-aasland commented on Jan 17, 2022

      @erlend-aasland
      erlend-aasland
      on Jan 17, 2022
      Contributor
      More actions

      IMO, the URI "API" is not very pythonic; I have to look up the format every time I'm using it.

      OTOH, introducing flags, or keywords, for every option will add a lot of code.

    8. erlend-aasland commented on Jan 17, 2022

      @erlend-aasland
      erlend-aasland
      on Jan 17, 2022
      Contributor
      More actions

      OTOH, implementing an API similar to apsw (adding a flags keyword) would make it easier for users to switch between that and the stdlib sqlite3.

    9. nedbat commented on Jan 17, 2022

      @nedbat
      nedbat
      on Jan 17, 2022
      MemberAuthor
      More actions

      @erlend: thanks for the URI tip, I missed that as a possibility in the SQLite docs.

    10. erlend-aasland commented on Jan 17, 2022

      @erlend-aasland
      erlend-aasland
      on Jan 17, 2022
      Contributor
      More actions

      I guess we could do more to promote that trick in the docs. It’s quite useful.

    11. erlend-aasland commented on Jan 18, 2022

      @erlend-aasland
      erlend-aasland
      on Jan 18, 2022
      Contributor
      More actions

      I created #74845 in order to try to enhance the docs. Ned and Eric, would you mind taking a look at the PR?

    12. ericvsmith commented on Jan 18, 2022

      @ericvsmith
      ericvsmith
      on Jan 18, 2022
      Member
      More actions

      New changeset bdf2ab1 by Erlend Egeberg Aasland in branch 'main':
      bpo-46402: Promote SQLite URI tricks in sqlite3 docs (GH-30660)
      bdf2ab1

    13. nedbat commented on Jan 18, 2022

      @nedbat
      nedbat
      on Jan 18, 2022
      MemberAuthor
      More actions

      BTW, I'm fine with this being closed, since the functionality I wanted is available and documented.

    14. erlend-aasland commented on Jan 18, 2022

      @erlend-aasland
      erlend-aasland
      on Jan 18, 2022
      Contributor
      More actions

      BTW, I'm fine with this being closed, since the functionality I wanted is available and documented.

      Great. I was considering closing it as soon as the backports have landed (I had to manually fix them bco. make suspicious failures).

    15. ericvsmith commented on Jan 18, 2022

      @ericvsmith
      ericvsmith
      on Jan 18, 2022
      Member
      More actions

      New changeset 01e6cbe by Erlend Egeberg Aasland in branch '3.10':
      [3.10] bpo-46402: Promote SQLite URI tricks in sqlite3 docs (GH-30660) (GH-30671)
      01e6cbe

    16. ericvsmith commented on Jan 18, 2022

      @ericvsmith
      ericvsmith
      on Jan 18, 2022
      Member
      More actions

      New changeset 0ae2257 by Erlend Egeberg Aasland in branch '3.9':
      [3.9] bpo-46402: Promote SQLite URI tricks in sqlite3 docs (GH-30660) (bpo-30672)
      0ae2257

    17. erlend-aasland commented on Jan 18, 2022

      @erlend-aasland
      erlend-aasland
      on Jan 18, 2022
      Contributor
      More actions

      Closing this. Thanks, Ned and Eric!

    18. erlend-aasland
      closed this as completedon Jan 18, 2022
    19. erlend-aasland
      closed this as completedon Jan 18, 2022
    20. ezio-melotti
      transferred this issue fromon Apr 10, 2022
    21. erlend-aasland
      added
      topic-sqlite3
      on May 16, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      3.11only security fixesonly security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-sqlite3type-featureA feature request or enhancementA feature request or enhancement

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions

        You are visitor 01402503 — GeezerVison does not store the pages you look up.
        Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.