Skip to content

Sending the sqlite3 autocommit parameter renders this PRAGMA command a no-op #137205

@panovitcin

Description

@panovitcin

Bug report

Bug description:

root issue is here ( discussed w\ @zzzeek ): sqlalchemy/sqlalchemy#12767

An explicit emit of the autocommit attribute (=False) makes PRAGMA command not work. Example of the code:

engine = create_async_engine(
    config.SQLITE_URL,
    echo=True,
    connect_args={"autocommit": False},
    poolclass=NullPool
)

@event.listens_for(engine.sync_engine, "connect", named=True)
def enable_foreign_keys(dbapi_connection: AsyncAdapt_aiosqlite_connection, connection_record):
    cursor = dbapi_connection.cursor()
    cursor.execute("PRAGMA foreign_keys=ON")
    cursor.execute("PRAGMA foreign_keys")
    result = cursor.fetchone() 
    print(f"Foreign keys pragma value: {result}")
    cursor.close()

CPython versions tested on:

3.13

Operating systems tested on:

Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibPython modules in the Lib dirtopic-sqlite3type-bugAn unexpected behavior, bug, or error

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy