On 22 April 2016 at 02:02, <john.rg....@gmail.com> wrote:

> Yeah, good call perhaps.  We're certainly drawn to raw sql (which we all
> know fairly well) compared to learning Django's tricks for complex queries,
> but the originator of our project chose to write lots of unit tests using
> sqlite (instead of our production mysql) for speed and simplicity reasons
> (notwithstanding questions of incompatibility) - so an ORM offers some
> extra value currently due to SQL differences that can be handled
> automatically.  On first glance SA appears a little more like SQL than
> Django's query language - though I'm sure there's times when I may tear my
> hair out wanting raw SQL.



If may suggest something.. sqllite with :inmemory: backend will improve
speed of tests, indeed, but you will be still limited in expressing
yourself because of dialect differences. You will need to "speak" using
"common words" and drop away power of the specific database engine.
SQLAlchemy has a marvelous expressions API, it covers more features than
Django, but also it allows to build queries with direct embedding SQL
literals and even parts of the query (`sqlalchemy.text()`). So it is a
matter of time when your queries will become dialect-specific. Or your unit
tests will block you get the things done...

In my tests I'm using many database engines. Many of tests are
non-transactional, i.e. using django.test.TestCase as a base class (where
every test starts with `BEGIN` and ends with `ROLLBACK`). And the most
time-consuming operations are cleaning databases and loading fixtures for
every test. So I removed them by overridng some of Django`s methods. I'm
using factories instead of fixtures and ROLLBACK-ing after every test to
avoid slow cleaning. As a result test suites are running quite fast without
switching to SQLite, so I don't have to wrap everything into ORM and I can
use specific features of each db.

Kind Regards,
Marcin

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAB2m7CwOZBJyDHiE-B_3FMZa6PA6rTnzprbuKwi2OEtCMtg6ow%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to