Mark | 1 Jul 2010 17:48
Picon

Re: select only specified columns

Even if you weren't using SQLObject I believe it would make more 
sense to create a separate name/id table and then only select 
from the 40 column table when you know what row you want.

Mark

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
Oleg Broytman | 1 Jul 2010 18:28
X-Face
Picon
Favicon

Re: select only specified columns

On Thu, Jul 01, 2010 at 03:48:38PM +0000, Mark wrote:
> Even if you weren't using SQLObject I believe it would make more 
> sense to create a separate name/id table and then only select 
> from the 40 column table when you know what row you want.

   Or use a VIEW.

Oleg.
--

-- 
     Oleg Broytman            http://phd.pp.ru/            phd <at> phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
Petr Jakeš | 1 Jul 2010 20:14
Picon

Re: select only specified columns

+1
VIEW is, IMHO, en excelent way to go, when the SQLObject is close to its limits.

Petr


On 1 July 2010 18:28, Oleg Broytman <phd <at> phd.pp.ru> wrote:
On Thu, Jul 01, 2010 at 03:48:38PM +0000, Mark wrote:
> Even if you weren't using SQLObject I believe it would make more
> sense to create a separate name/id table and then only select
> from the 40 column table when you know what row you want.

  Or use a VIEW.

Oleg.
--
    Oleg Broytman            http://phd.pp.ru/            phd <at> phd.pp.ru
          Programmers don't die, they just GOSUB without RETURN.

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss
Mark | 1 Jul 2010 20:38
Picon

Re: select only specified columns


> +1VIEW is, IMHO, en excelent way to go, when the SQLObject is close to its 
> limits.Petr

How do you create and use a view in SQLObject? 

And is not a view a tradeoff on response time vs DB size? If I create a separate 
table with a million rows I may add 50mb to the DB size, but if I use a view the 
DB has to select out the view each time and that 50mb may not cache. 

Mark

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
Mark | 1 Jul 2010 20:47
Picon

Sorting a list of selected SQLObjects

I just set up my own forum, and am attempting to sort a user's subscriptions
by the last post in each thread(BBTopic). However the sorted function is 
failing saying lambda only takes 1 argument but was given 2. I use this
sorted function on lists of non SQLObject objects and it works fine for me.

Can you use sorted with a list returned from a select? 

Or is there a way for me to rewrite this? Perhaps using orderBy?

        subs_sel = list(BBSubs.select(BBSubs.q.user_id==1))
        for sub in subs_sel:
            sub.topic = BBTopic.get(sub.topic_id)
            sub.post  = BBPost.get(sub.topic.last_post_id)
            sub.forum = BBForum.get(sub.topic.forum_id)

        subs = sorted(subs_sel, lambda x: x.topic.last_post_id)

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
Petr Jakeš | 1 Jul 2010 20:52
Picon

Re: select only specified columns

Creat View in the SQL and than use it in the SQLObject as an ordinary table.
You can handle some more complex SQL SELECT  within the view.

Of course it is read only (I am on Firebird - maybe some other databases behave differently)

HTH

Petr

On 1 July 2010 20:38, Mark <markreed99 <at> gmail.com> wrote:

> +1VIEW is, IMHO, en excelent way to go, when the SQLObject is close to its
> limits.Petr

How do you create and use a view in SQLObject?

And is not a view a tradeoff on response time vs DB size? If I create a separate
table with a million rows I may add 50mb to the DB size, but if I use a view the
DB has to select out the view each time and that 50mb may not cache.

Mark



------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss
Oleg Broytman | 1 Jul 2010 21:31
X-Face
Picon
Favicon

Re: select only specified columns

On Thu, Jul 01, 2010 at 08:52:38PM +0200, Petr Jake?? wrote:
> Creat View in the SQL and than use it in the SQLObject as an ordinary table.
> You can handle some more complex SQL SELECT  within the view.

   +1

> Of course it is read only (I am on Firebird - maybe some other databases
> behave differently)

   Yes, there are VIEWs that support updating.

   Another way is to use ViewSQLObject. See http://sqlobject.org/Views.html

Oleg.
--

-- 
     Oleg Broytman            http://phd.pp.ru/            phd <at> phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
Oleg Broytman | 1 Jul 2010 21:35
X-Face
Picon
Favicon

Re: Sorting a list of selected SQLObjects

On Thu, Jul 01, 2010 at 06:47:59PM +0000, Mark wrote:
> I just set up my own forum, and am attempting to sort a user's subscriptions
> by the last post in each thread(BBTopic). However the sorted function is 
> failing saying lambda only takes 1 argument but was given 2. I use this
> sorted function on lists of non SQLObject objects and it works fine for me.
> 
> Can you use sorted with a list returned from a select? 
> 
> Or is there a way for me to rewrite this? Perhaps using orderBy?
>  
> 
>         subs_sel = list(BBSubs.select(BBSubs.q.user_id==1))
>         for sub in subs_sel:
>             sub.topic = BBTopic.get(sub.topic_id)
>             sub.post  = BBPost.get(sub.topic.last_post_id)
>             sub.forum = BBForum.get(sub.topic.forum_id)

   Why do you assign values explicitly Why not to use ForeignKey?

>         subs = sorted(subs_sel, lambda x: x.topic.last_post_id)

   I don't see any problem with the code. Can you write a short standalone
script that I can run to see the problem?

Oleg.
--

-- 
     Oleg Broytman            http://phd.pp.ru/            phd <at> phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
Oleg Broytman | 2 Jul 2010 17:41
X-Face
Picon
Favicon

Re: Creating SQL connection to Postgres over SSL

Hello.

   I just added 'sslmode' to PostgresConnection - see commit 4199 in the
Subversion repository. The syntax is

postgresql://cumin <at> localhost/cumin?sslmode=require

   It only works with psycopg[12] backends, and those backends only
understand 'sslmode' parameter - not certificate/keyfile/CA.

Oleg.
--

-- 
     Oleg Broytman            http://phd.pp.ru/            phd <at> phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
Oleg Broytman | 2 Jul 2010 17:46
X-Face
Picon
Favicon

Re: Creating SQL connection to Postgres over SSL

On Fri, Jul 02, 2010 at 07:41:30PM +0400, Oleg Broytman wrote:
>    It only works with psycopg[12] backends, and those backends only
> understand 'sslmode' parameter - not certificate/keyfile/CA.

   Sorry - psycopg *drivers*.

Oleg.
--

-- 
     Oleg Broytman            http://phd.pp.ru/            phd <at> phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first

Gmane