[Python] Migrating Engine.execute to SQLAlchemy 2.0

Discussão em 'Python' iniciado por Stack, Fevereiro 9, 2025.

  1. Stack

    Stack Membro Participativo

    I am running my Python script using sqlite package sqlalchemy.

    In sqlalchemy 1.4 version my statements look like this:

    from sqlalchemy import create_engine, text

    results = engine.execute(text("""SELECT * from ragas"""))


    I am trying to migrate it into sqlalchemy 2.0 version as follows:

    from sqlalchemy import create_engine, text

    with engine.connect() as connection:

    results = connection.execute(text("""SELECT * from ragas"""))


    I am getting the error:


    TypeError: 'module' object is not callable.
    ​

    What is the correct way of writing this code in sqlalchemy 2.0?

    Continue reading...

Compartilhe esta Página