On Friday, August 14, 2020 at 10:00:46 AM UTC-4, Alceu Rodrigues de Freitas 
Junior wrote:
 

> I have some projects that are using SQLAlchemy and PostgreSQL and they are 
> running fine until we have to run automated tests that uses PostgreSQL and 
> they took ~5 minutes to complete, even after trying to improve PostgreSQL 
> configuration for better performance.
>
> Those tests are meant to be executed locally, so SQLite (in memory) would 
> be a much faster option.
>

I usually target PostgreSQL production and continuous-integration, and 
SQLite for developer testing and unit-tests..  There are some tradeoffs on 
leveraging SQLlite in-memory vs file-based regarding: locking, concurrency, 
and per-test setups.  In my experience, a file-backed sqlite is better on 
higher-level tests and memory-backed is otherwise fine..


The problem is, creating a model for the SQLite dialect results in 
> something incompatible with PostgreSQL (I'm quite aware that their inner 
> mechanisms are very different).
>
> Is it possible to generate models that could be compatible between the two 
> databases systems, so I could switch from to another depending on the 
> environment? Retaining data is not something required since all data 
> created from the tests will be disposable anyway.
>

Exactly what issues are you having, and why do you need to create a 
different model?  You should be able to use the same model for both.

When it comes to managing core differences between the databases - like the 
very different database functions --  I use the @compiles decorator to 
write custom functions that will compile differently on each backend.

What you're talking about is a very common usage of SqlAlchemy. Please 
share more details so we can help you get up and running.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/e0e326d1-fcf9-47c0-a71f-d23fd8401b55o%40googlegroups.com.

Reply via email to