4 ms·
The problem is with using `session.add(obj)` instead of `session.scalars(insert(TheClass).returning(TheClass), data)`. If there's a way to get generated SQL fro
by nerdponx 3y ago
The problem is with using `session.add(obj)` instead of `session.scalars(insert(TheClass).returning(TheClass), data)`. If there's a way to get generated SQL from an AsyncSession, please do let me know.
- camgunz 3y agoI think you have a couple options [0], I currently have a project that uses 'echo' in debug mode. [0]: https://stackoverflow.com/questions/27748053/how-to-log-sql-statements-and-rows-returned-in-sqlalchemy-to-aid-in-debugging#27748054 https://stackoverflow.com/questions/27748053/how-to-log-sql-...
- nerdponx 3y agoYep, that's the same output that's emitted in the sqlalchemy.engine logger. If you use the logger you can use Pytest caplog to capture it.
- perlgeek 3y agoThis is a very blunt tool, but `engine.echo = True` prints all SQL going to the DB. (I don't have any experience with AsyncSession, so cannot contribute something more specific)