On Aug 27, 2017 12:26 PM, "Thorsten Kampe" <thors...@thorstenkampe.de>
wrote:

* Mike Bayer (Sun, 27 Aug 2017 11:35:27 -0400)
>
> On Sun, Aug 27, 2017 at 9:52 AM, Thorsten Kampe
> <thors...@thorstenkampe.de> wrote:
> > Hi,
> >
> > is it possible to enable autocommit for a MSSQL
> > connection with Pymssql? The feature is available in
> > Pymssql since 2014. PyODBC - the default MSSQL driver -
> > supports autoconnect in the connection string.
> >
> > I have been unsuccessful trying to enable autocommit in
> > the connection string or as a keyword for
> > `create_engine` (`isolation_level = 'AUTOCOMMIT'` or
> > `autocommit = True`).
>
> the pyodbc connector does accept 'autocommit' as a query parameter
> which will be coerced to boolean, so this should work:
>
> create_engine("mssql+pyodbc://scott:tiger@dsn?autocommit=true")

Thanks for the quick answer. My question was
specifically about the PyMSSQL driver (not the PyODBC
driver).

The reason why I'm asking is that I would like to
connect from Linux.

PyODBC works fine on Windows. On Linux I simply don't
know what to use instead of...

    driver=SQL+Server+Native+Client+11.0

...in the connection string when using a "Hostname-
based connection".


You use the ODBC connector that comes with FreeTDS in conjunction with
UnixODBC.   That said, pymssql probably works a little better on linux so
you can set this autocommit flag using a connect hook (
http://docs.sqlalchemy.org/en/latest/core/events.html?highlight=connect#sqlalchemy.events.PoolEvents.connect)
or we can accept a PR for a real feature addition.





Thorsten

--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and
Verifiable Example.  See  http://stackoverflow.com/help/mcve for a full
description.
---
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to