aioodbc context managers

110 views
Skip to first unread message

iliev....@gmail.com

unread,
Jul 31, 2018, 5:25:21 PM7/31/18
to aio-libs
Hello,

according to pyodbc documentation: 

When using cursor/connection context manager, going out of scope have to
automatically commit the changes if autocommit is False.

The  _ContextManager.__aexit() invoke .close() but not commit() or rollback().
I think, the correct implementation should be:

async def __aexit__(self, exc_type, exc_value, traceback):
if exc_type:
await self.cursor.rollback()
elif not self.cursor.connection.autocommit:
await self.cursor.commit()
await self.cursor.close()



Nickolai Novik

unread,
Aug 1, 2018, 4:48:28 AM8/1/18
to iliev....@gmail.com, aio-libs
Good point, aioodbc tries to have very similar API to pyodbc, so we should have similar context managers. Would you like to submit PR with mentioned change and test case?

--
You received this message because you are subscribed to the Google Groups "aio-libs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to aio-libs+u...@googlegroups.com.
To post to this group, send email to aio-...@googlegroups.com.
Visit this group at https://groups.google.com/group/aio-libs.
To view this discussion on the web visit https://groups.google.com/d/msgid/aio-libs/6320cd02-26e4-4ed0-9a86-a8ed99aad1bb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

iliev....@gmail.com

unread,
Aug 1, 2018, 11:26:45 AM8/1/18
to aio-libs
Sure, I would give a try.

iliev....@gmail.com

unread,
Aug 4, 2018, 1:31:42 PM8/4/18
to aio-libs
Hi Nikolay,

Thank you for merging the changes!

I would like to kindly ask you for a couple of more things. 
Please,  update the version of aioodbc and the Changes.txt. 
When download aioodbc I still see the old source code despite the changes being merge to master. 
We have a script that automatically download python libs, and as I am in the middle of a project it will be extremely useful
to have the updated library. I will be able to clean some of the code. 
Do you think this could be done in a short time?
If you need any help please let me know.

Kind regards,
Yulian ILiev

Nickolai Novik

unread,
Aug 4, 2018, 3:38:10 PM8/4/18
to iliev....@gmail.com, aio-libs
Sure thing, I am planning to deploy new release this weekend.

--
You received this message because you are subscribed to the Google Groups "aio-libs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to aio-libs+u...@googlegroups.com.
To post to this group, send email to aio-...@googlegroups.com.
Visit this group at https://groups.google.com/group/aio-libs.
Reply all
Reply to author
Forward
0 new messages