Re: [sqlalchemy] How to force the engine to "glue" objects together the way it does when you run a query?

2018-09-29 Thread Mike Bayer
My advice is to simply make a sqlite memory database for testing which is an almost universal pattern for test suites. You can even make a database per test, that's a common pattern. Otherwise you have to mock everything and yes "double job" it. The ORM doesn't want to "double job" it either,

Re: [sqlalchemy] How to force the engine to "glue" objects together the way it does when you run a query?

2018-09-29 Thread seaders
I've made my system with SQLAlchemy objects pretty pivotal to how it runs. For testing, I'm not actually testing the dB, I'm testing other areas of flow of my project, so - as much as possible - I don't necessarily want to change its setup. I would just like to have a kind of "snapshot" of my

Re: [sqlalchemy] How to force the engine to "glue" objects together the way it does when you run a query?

2018-09-29 Thread Mike Bayer
On Sat, Sep 29, 2018 at 11:18 AM seaders wrote: > > Yes, that's exactly what I want. No queries to the database, at any time > exactly. > > However, doing that, I get > > sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such table: > sport [SQL: 'INSERT INTO sport ...]

Re: [sqlalchemy] How to force the engine to "glue" objects together the way it does when you run a query?

2018-09-29 Thread seaders
Yes, that's exactly what I want. No queries to the database, at any time *exactly*. However, doing that, I get sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such table: sport [SQL: 'INSERT INTO sport ...] (Background on this error at: http://sqlalche.me/e/e3q8) I haven't

Re: [sqlalchemy] How to force the engine to "glue" objects together the way it does when you run a query?

2018-09-29 Thread Mike Bayer
On Sat, Sep 29, 2018 at 7:34 AM seaders wrote: > > Yep, that helps, nearly doing what I want. > > I have a "from_flat_json" function in my base class, so that's a perfect > place to add the `session.enable_relationship_loading` bit for any created > objects - that's now working, which is great.

Re: [sqlalchemy] How to force the engine to "glue" objects together the way it does when you run a query?

2018-09-29 Thread seaders
Yep, that helps, nearly doing what I want. I have a "from_flat_json" function in my base class, so that's a perfect place to add the `session.enable_relationship_loading` bit for any created objects - that's now working, which is great. Only thing that's not wanted / right just yet is the