Re: Creating database views, functions, stored procedures etc

2013-06-20 Thread akaariai
On 20 kesä, 14:32, Mark Robson  wrote:
> Hi,
>
> I've got a Django application which uses a mixture of managed and unmanaged
> models.
>
> The managed models get their tables created in the usual way, the unmanaged
> ones via a number of .sql files in the application/sql directory.
>
> This works fine, but I also have some views and user-defined functions in
> the database. Until now I've been manually creating these after
> installation.
>
> However, I'm trying to add better unit-tests, some of which will need to
> use the views and functions.
>
> I've done a lot of research and apparently drawn a blank on this. I can
> hook the post_syncdb signal in my application, but this is executed after
> syncdb, but before custom SQL has been run.
>
> Or alternatively, I could "tack on" the views and functions to one of my
> models' .sql files, and hope that it works - but of course, the views are
> executing joins, so I need the tables they depend upon to be all created
> beforehand.
>
> (NB: I'm using Postgresql, if it makes any difference)
>
> Does anyone have a suggestion for how to handle this?
>
> Thanks
>
> Mark

You will likely want to use a custom test runner. Override its
setup_databases method and run your custom SQL there.

 - Anssi

-- 
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 http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Creating database views, functions, stored procedures etc

2013-06-20 Thread Mark Robson
Hi,

I've got a Django application which uses a mixture of managed and unmanaged 
models.

The managed models get their tables created in the usual way, the unmanaged 
ones via a number of .sql files in the application/sql directory.

This works fine, but I also have some views and user-defined functions in 
the database. Until now I've been manually creating these after 
installation.

However, I'm trying to add better unit-tests, some of which will need to 
use the views and functions.

I've done a lot of research and apparently drawn a blank on this. I can 
hook the post_syncdb signal in my application, but this is executed after 
syncdb, but before custom SQL has been run.

Or alternatively, I could "tack on" the views and functions to one of my 
models' .sql files, and hope that it works - but of course, the views are 
executing joins, so I need the tables they depend upon to be all created 
beforehand.

(NB: I'm using Postgresql, if it makes any difference)

Does anyone have a suggestion for how to handle this?

Thanks

Mark

-- 
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 http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.