Frank Wagner | 2 Apr 12:26
Picon

SQLObject, Unicode and fromDatabase=True

Hello guys,

it´s me again with another unicode problem.

when i define my class like this, everything works fine:

class myclass(SQLObject):
  sqlmeta: pass
  firstname=UnicodeCol()
  lastname=UnicodeCol()

but when i define it like this (because it´s a legacy-table) i receive
an error because of the unicoded cols (containing german umlauts) in
the table:

class myclass(SQLObject):
  sqlmeta:
    fromDatabase=True

i get an error!

how can i make fromDatabase-columns use UnicodeCols instead of StringCols?

Regards,
Frank
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
(Continue reading)

Oleg Broytmann | 2 Apr 12:50
X-Face
Picon
Favicon

Re: SQLObject, Unicode and fromDatabase=True

On Mon, Apr 02, 2007 at 12:26:46PM +0200, Frank Wagner wrote:
> class myclass(SQLObject):
>   sqlmeta:
>     fromDatabase=True
> 
> i get an error!
> 
> how can i make fromDatabase-columns use UnicodeCols instead of StringCols?

   Add "use_unicode" parameter to DB URI:

db_uri = "mysql:/...&use_unicode=1..."

   It forces all columns drawn from database to be UnicodeCol instead of
StringCol.

Oleg.
--

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

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
MichaelG | 5 Apr 01:50

Multi-Key Sort Question in 0.8


I have struggled for some time with the multi-key sort issue in 
SQLObject 0.8, and I can't seem to find any comments on the mailing list 
lately (if at all) that are on-point, at least for my newbie level of 
understanding, so I thought I'd throw this question out there, to see 
what the best approach would be.

Is there an SQLObject way to do a sort using 2 or more keys without 
hand-crafted SQL code?

Example:  Let's say we have a table called Music, with columns:

Artist
Year
TrackName

And we want to get a sorted list showing all the TrackNames, but sorted 
first by Year, and then by Artist and TrackName.

1967
   Joplin
     Song 1
     Song 2
   Hendrix
     Song A
     Song B
1968
   Joplin
     Song 3
     Song 4
(Continue reading)

Oleg Broytmann | 5 Apr 09:09
X-Face
Picon
Favicon

Re: Multi-Key Sort Question in 0.8

On Wed, Apr 04, 2007 at 04:50:31PM -0700, MichaelG wrote:
> SELECT Year, Artist, TrackName FROM Music ORDER BY Year, Artist, Track
> 
> What if any is the equivalent syntax in SQLObject for this kind of 
> multi-key sort?  All I can find is the single column syntax for orderBy, 
> but I am not sure how to render this as a 2 or more key argument.

   Use a list:

Music.select(orderBy=[Music.q.year, Music.q.artist, Music.q.track])

Oleg.
--

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

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
MichaelG | 5 Apr 18:25

Re: Multi-Key Sort Question in 0.8

Oleg Broytmann wrote:
> On Wed, Apr 04, 2007 at 04:50:31PM -0700, MichaelG wrote:
>> SELECT Year, Artist, TrackName FROM Music ORDER BY Year, Artist, Track
>>
>> What if any is the equivalent syntax in SQLObject for this kind of 
>> multi-key sort?  All I can find is the single column syntax for orderBy, 
>> but I am not sure how to render this as a 2 or more key argument.
> 
>    Use a list:
> 
> Music.select(orderBy=[Music.q.year, Music.q.artist, Music.q.track])
> 
> Oleg.
----

Works like a charm, thanks, Oleg.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
Aaron Digulla | 9 Apr 16:30
Favicon
Gravatar

Working with (ordered) lists

Hello,

Is it possible to store and load an ordered list of items with SQLObject?

In my specific case, I have a recursive data structure:

class Knowledge(SQLObject):
    parent = ForeignKey('Knowledge')
    children = MultipleJoin('Knowledge', joinColumn='parent_id',
orderBy='pos')
    pos = IntCol(default=0)

How do I make sure "pos" is assigned the correct value when I add
children to a node? Should I override _set_parent() or addChildren()?

Or should I manage the list of children myself using a "hidden" field
which implements the DB access to load all children?

Regards,

--

-- 
Aaron "Optimizer" Digulla a.k.a. Philmann Dark
"It's not the universe that's limited, it's our imagination.
Follow me and I'll show you something beyond the limits."
http://www.pdark.de/

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
(Continue reading)

Oleg Broytmann | 9 Apr 16:41
X-Face
Picon
Favicon

Re: Working with (ordered) lists

On Mon, Apr 09, 2007 at 04:30:30PM +0200, Aaron Digulla wrote:
> Or should I manage the list of children myself using a "hidden" field
> which implements the DB access to load all children?

   This is the way to go, I think.

Oleg.
--

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

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
Mathias Stearn | 9 Apr 17:17
Picon
Favicon

Re: Working with (ordered) lists

If the lists are likely to be small you can use a PickleCol that
stores a python list.

On 4/9/07, Aaron Digulla <digulla <at> hepe.com> wrote:
> Hello,
>
> Is it possible to store and load an ordered list of items with SQLObject?
>
> In my specific case, I have a recursive data structure:
>
> class Knowledge(SQLObject):
>     parent = ForeignKey('Knowledge')
>     children = MultipleJoin('Knowledge', joinColumn='parent_id',
> orderBy='pos')
>     pos = IntCol(default=0)
>
> How do I make sure "pos" is assigned the correct value when I add
> children to a node? Should I override _set_parent() or addChildren()?
>
> Or should I manage the list of children myself using a "hidden" field
> which implements the DB access to load all children?
>
> Regards,
>
> --
> Aaron "Optimizer" Digulla a.k.a. Philmann Dark
> "It's not the universe that's limited, it's our imagination.
> Follow me and I'll show you something beyond the limits."
> http://www.pdark.de/
>
(Continue reading)

j j | 9 Apr 23:24
Picon

using mxDateTime by default

Hello,

I am working with an existing application that uses mxDateTime therefore, I am wondering if there is a straightforward way to set default_datetime_implementation to mxDateTime(perhaps when configuring the connection). Any advice would be appreciated.

Regards,

Joe





-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss
Oleg Broytmann | 10 Apr 08:44
X-Face
Picon
Favicon

Re: using mxDateTime by default

On Mon, Apr 09, 2007 at 02:24:17PM -0700, j j wrote:
> I am working with an existing application that uses mxDateTime therefore, I
> am wondering if there is a straightforward way to set
> default_datetime_implementation to mxDateTime

from sqlobject import *
from sqlobject import col

if mxdatetime_available:
    col.default_datetime_implementation = MXDATETIME_IMPLEMENTATION

   Do this *before* defining your classes. See test_datetime.py for an
example.

> (perhaps when configuring the connection).

   Unfortunately it is hard to reset the validator/converter based on
connection settings; so if you need two connections in one program
(SQLObject allows this), one with datetime and the other with mxDateTime,
you have to create two different classes.

Oleg.
--

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

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

Gmane