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

[Question] Is there any plan for testing upsert with sqlalchemy 2.0 API? #37

Closed
jensqin opened this issue Jun 21, 2021 · 1 comment · Fixed by #41
Closed

[Question] Is there any plan for testing upsert with sqlalchemy 2.0 API? #37

jensqin opened this issue Jun 21, 2021 · 1 comment · Fixed by #41

Comments

@jensqin
Copy link

jensqin commented Jun 21, 2021

Firstly I want to say thank you! This project is super helpful for me!

According to sqlalchemy 1.4 documentation,
SQLAlchemy 2.0 presents a major shift for a wide variety of key SQLAlchemy usage patterns in both the Core and ORM components.
One big change is the "autocommit" feature is deprecated since 1.4.

I ran a simple test using the future flag on engine, and upsert is not working with the engine. No errors showed up, but the table in database remains the same, which made me wonder if it is related to the "autocommit" feature. Details here.

@ThibTrip
Copy link
Owner

Hi @jensqin ! Thanks for the issue. I had a first look into it. See branch WIP-sqlalchemy_v2.

I had the same behavior as you where no updates were made. I tried this:

with engine.connect().execution_options(autocommit=True) as connection:
    result = connection.execute(...)

That did not work so I went for:

with engine.connect() as connection:
    result = connection.execute(...)
    connection.commit()

I was able to pass all tests except for test_crappy_text_insert in module pangres/tests/test_upsert.py. I don't understand why it doesn't pass yet 🤔 .

There are also retrocompability problems which will require some automatic switches depending on the sqlalchemy version (that should not be a big deal I think, we had a similar situation with v1.4).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants