Re: [sqlalchemy] Re: Register function example (perhaps) to remove tab, newline or carriage return from column.

2018-02-14 Thread Jonathan Vanasco
On Wednesday, February 14, 2018 at 6:49:47 AM UTC-5, Simon King wrote: > For what it's worth, I would do it something like this: > that's elegant. I'd rather do that now too. -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post

Re: [sqlalchemy] How right use session/scoped_session in web app?

2018-02-14 Thread Simon King
I think there are a couple of problems with this. 1. You are calling scoped_session and sessionmaker every time the decorated function is called, which is unnecessary. sessionmaker returns a factory function for creating sessions, so you typically only have one sessionmaker() call in your

Re: [sqlalchemy] How right use session/scoped_session in web app?

2018-02-14 Thread eugene . deneb
Decorator like this engine = create_engine( 'mssql+pymssql://{LOGIN}:{PASSWORD}@{HOST}/{DATABASE}?charset={CHARSET}={TIMEOUT}'.format(**DATABASE), isolation_level='READ COMMITTED' ) def decorator_with_args(decorator_to_enhance): """ https://habrahabr.ru/post/141501/ """

Re: [sqlalchemy] How right use session/scoped_session in web app?

2018-02-14 Thread Simon King
The pattern you should be aiming for is one in which a fresh transaction is started for every web request that touches the database, and that the transaction is closed at the end of the request. How are you ensuring that at the moment? Simon On Wed, Feb 14, 2018 at 12:51 PM,

Re: [sqlalchemy] How right use session/scoped_session in web app?

2018-02-14 Thread eugene . deneb
If I run tests where all functions run one-by-one - all tests passed. But when i run web app and functions can call almost in parallel then i have a problem, then there are problems - transactions can block each other. I tried to set the isolation level of SNAPSHOT and READ COMMITTED, but it did

Re: [sqlalchemy] running py.test

2018-02-14 Thread Simon King
The error is coming from here: https://github.com/zzzeek/sqlalchemy/blob/master/lib/sqlalchemy/testing/mock.py So I guess you could start by adding some print statements in that file to see where the exception is being raised. Perhaps you have a different "mock.py" somewhere on the PYTHONPATH

Re: [sqlalchemy] How right use session/scoped_session in web app?

2018-02-14 Thread eugene . deneb
Hello, Mike! In my web app i have many selects like session.execute(select([table1]).where(condition)) and not so much updates, inserts and deletes like session.execute(update(table1).where(condition).values(**values)) session.execute(insert(table1).values(**values))

Re: [sqlalchemy] Re: Register function example (perhaps) to remove tab, newline or carriage return from column.

2018-02-14 Thread Simon King
On Fri, Feb 9, 2018 at 7:38 PM, Jeremy Flowers wrote: > And I do want to use this functionality repeatedly on many columns, hence > the idea of registering a function. > For what it's worth, I would do it something like this: def removechars(col, chars): for c in