Johann, what about creating a postgres view with you query and then just
interface it as table in web2py... Of course you will not be able to do any
of CRUD, but you can select/consult you data. I do that for many usage, for
instance get a subset of membership user id, for reporting (my report is a
build up of many different views, it slow but it work until I hack a
function/stored procedure)...

Hope it helps.

Richard


On Thu, Nov 14, 2013 at 8:18 AM, Johann Spies <johann.sp...@gmail.com>wrote:

> I want to work with a selection of article_id's in combination with
> publication year.
>
> This list of records can anything form a few to many thousands.  To use
> .belongs(listofthousands) is very slow so I am thinking of using
> Postgresql's create table temptable as (select ...) and then in the
> controller do a db.define_table(temptable) and run the query not as
> belongs.(longlist) but with something like db.x.art_id ==
> db.tmptable.art_id in stead.
>
> So far so good.  But this can happen in more than one function.  So I
> cannot have a situation where I do
>
> DROP TABLE tmptable if exists;
> CREATE TABLE tmptable as (SELECT ...)
>
> where the possibility exists that more than one user may use the same
> tmptable from the same or different function.
>
> How do I ensure that a temporary table is unique to the user in a specific
> session and that it gets cleaned up afterwords?
>
> I thought of a situation where I link the tmptable name to auth.user_id,
> but what if a user wants to do a lot work in parallel an use four different
> browsers (like I do from time to time).  I found that I cannot do parallel
> work from one browser if a background query is running initiated from that
> browser.
>
> I suspect I can use the session to determine the tablename or something
> like uuid and then keep it as a session-variable.  How do I ensure then
> that the temptable gets dropped when the user log out or the session is
> over?
>
> Regards
> Johann
>
> --
> Because experiencing your loyal love is better than life itself,
> my lips will praise you.  (Psalm 63:3)
>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to