On Aug 3, 11:38 pm, Ryan <[email protected]> wrote:
> I followed this how-to (http://farmdev.com/projects/fixture/using-
> fixture-with-pylons.html) on using fixtures with Pylons, which was
> written for 0.9.7. In the `tests/__init__.py` file, an
> `SQLAlchemyFixture` object needs to be instantiated, which requires a
> reference to an SQLAlchemy engine. I'm sure this must be loaded
> somewhere in the environment,
This will only be true if you enabled the SQLAlchemy option when
creating the project or you added the SQLAlchemy setup yourself, since
Pylons itself makes no assumptions about how (or if) you connect to a
database.
Is this a new project? Is there a model.meta module in your project?
Did the tests work under 0.9.7? Can you paste up a copy of your
environment.py?
> but the suggested `meta.engine` is not
> correct for 1.0 and I was not able to find it, so I went with this
> instead.
>
> import sqlalchemy as sa
> engine = sa.create_engine('mysql://user:p...@localhost:3306/app_name')
>
> dbfixture = SQLAlchemyFixture(
> env = model,
> engine = engine,
> style = NamedDataStyle())
>
> Ugly.
I don't think this is particularly ugly. The only thing would be that
if you already have some database connection machinery in your
project, you might want to reuse it (but not necessarily, which is why
I don't think this is ugly).
> Can anyone tell me the best way to reference the engine?
Not without knowing how your project is structured/configured.
--
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/pylons-discuss?hl=en.