Alex | 29 Jun 20:33

Unicode in mysql issue

Hi all,
How to retreive unicode data from a mysql table with SQLObject?
When I run this code:
class Foo(SQLObject):
    class sqlmeta:
        fromDatabase = True
print Foo.select(Foo.q.id==55)[0].bar
...I get:
"?????????? ????????????? ???????? ?? ?????????? ?????? ? ???"
bar's type is mediumtext and collation is utf8_general_ci.

Bests,
Alex

------------------------------------------------------------------------------
Markos Kapes | 28 Jun 03:18

Unicode w/ sqlobject

OK, so I have a simple object:
class PrimaryDef(SQLObject):
     _connection=sqlobject.connectionForURI("mysql:// 
infoshopkeeper <at> localhost/lexiko? 
use_unicode=1&charset=utf8&sqlobject_encoding=utf-8")
     class sqlmeta:
         fromDatabase=True
If I try to add an ascii record, it works.
If I try to add a unicode record
	PrimaryDef(lemma=u"λήμμα῾῾)
		or even
	PrimaryDef(lemma=u"λήμμα῾῾).encode("utf-8")
I get the standard
/opt/local/Library/Frameworks/Python.framework/Versions/2.5/lib/ 
python2.5/site-packages/sqlobject/dbconnection.pyc in _insertSQL(self,  
table, names, values)
     383         return ("INSERT INTO %s (%s) VALUES (%s)" %
     384                 (table, ', '.join(names),
--> 385                  ', '.join([self.sqlrepr(v) for v in values])))
     386
     387     def transaction(self):

UnicodeDecodeError: 'ascii' codec can't decode byte 0xce in position  
1: ordinal not in range(128)

So far so good, I'm still thinking that the connection isn't getting  
my  option keys to know it's supposed to be unicode an then chokes at  
sqlrepr, but if I just do
	PrimaryDef._connection.sqlrepr(u"λήμμα῾῾)
it gives me
(Continue reading)

Alex | 24 Jun 11:46

Using __connection__ in a multi-thread application

Is it thread safe to define __connections__ on the startup of a server
for the later use in multiple threads?

...
__connection__ = connectionForURI(connection_string)

class Person(SQLObject):
    ...

class MultithreadAppUsingPerson:
    ...
    persons = Person.select()
    ...

aMultithreadAppUsingPerson.run()

If it's not ok, how can I predefine connection for each thread without
the necessity to pass the connection explicitly on every
instantiation? I would really like to workaround the straightforward
code-consuming approach.

------------------------------------------------------------------------------
Imri Goldberg | 15 Jun 17:55

Trouble with cascade

Hi
I had some trouble with cascade='null' not being acted on when using deleteMany instead of destroySelf.
I managed to reproduce it with a simple example. When running the following code:

from sqlobject import *

class Abc(SQLObject):
    field1 = StringCol()
    final = ForeignKey('Abc', cascade='null')
    sources = MultipleJoin('Abc', joinColumn = 'finalID')

def main():
    conn = connectionForURI('sqlite:/:memory:')
    sqlhub.processConnection = conn
    #Abc._connection.debug = True
    Abc.createTable()

    a1 = Abc(field1='hello', final = None)
    a2 = Abc(field1='goodbye', final = a1)
    a3 = Abc(field1='gram', final = None)
    a4 = Abc(field1='shmidt', final = a3)
    a3.destroySelf()
    Abc.deleteMany(Abc.q.field1=='hello')
    print list(Abc.select())

if __name__ == '__main__':
    main()

The output is:
[<Abc 2 field1='goodbye' finalID=1>, <Abc 4 field1='shmidt' finalID=None>]
I would expect that both objects would have finalID set to None.

I'd appreciate any help with this.

Cheers,
Imri

--
Imri Goldberg
--------------------------------------
www.algorithm.co.il/blogs/
--------------------------------------
-- insert signature here ----
------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing 
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss
Matthew Wilson | 11 Jun 21:24
Favicon
Gravatar

MyTable.select(False).filter(False).count() crashes!

I get a weird error when I try to filter a selectResults object after
it is already empty.

It can be reproduced like this:

    >>> sr = MyTable.select(false) # obviously empty
    >>> sr.filter(False).count()
    TypeError: 'bool' object is unsubscriptable

This is a weird one.  I build a lot of dynamic queries and I don't
check as I add filters if I have an empty select results.

Is this a bug?  If so, I can try to fix.

Matt

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing 
server and web deployment.
http://p.sf.net/sfu/businessobjects
Joe Lanese | 11 Jun 16:11

Re: FW: longId=True handling...


This issue seems to be caused by a change in SQLObject.
The change in behaviour seems to be due to a change made in SQLObject in main.py, where the ‘idName’ attribute was taken out of a list of unshared attributes.  This caused the sqlmeta class to share the idName value with its containing class, so they both end up with ‘id’ even when longID is set to true in your own class.  If you add it back in:
_unshared_attributes = ['table', 'columns', 'childName', 'idName']
then it should work as before...however, I'm not sure if this will cause other problems (so far it seems to work).
 
It seems that the longID feature is broken unless this little change is made.  OR, are we misunderstanding the "new" way to make longID work properly?
 
By the way, here is a link to a change that seems to have triggered this change in behaviour:
http://www.mail-archive.com/sqlobject-discuss <at> lists.sourceforge.net/msg02159.html

Joe

 

From: Sam's Lists [mailto:samslists <at> gmail.com]
Sent: Wednesday, June 10, 2009 9:06 PM
To: sqlobject-discuss
Subject: [SQLObject] longId=True handling...

 

I posted this on the TurboGears mailing list but now I'm posting it here in hopes for more help.

Essentially I am upgrading from SQLObject 0.7.1dev_r1653 and MySQL 4.x something to MySQL 5 something and SQLObject 0.10.6

I have this very complicated legacy TurboGears application that I'm
tasked with upgrading to 1.0.8 which has laid stagnant since the days
of early .99 series.

The original author used the following a lot in his table definitions:

class sqlmeta:
        style = MixedCaseStyle(longID=True)

What this means is that instead of the id column being named 'id' it
takes on the name of the table...so if the table is called EventQueue,
the id column name is EventQueueID.

So far so good....but here's where it gets weird.

It appears that under the really old versions of TurboGears one could
refer to this EventQueueID as just .id and everything would work the
way you want it to.  (This appears to only be done in the app under
kid templates).

But now, under TG 1.0.8/the latest version of SQLObject that doesn't work.  Either I have to rename the
column to id or I have to refer to it as EventQueueID.

How can I make sqlObject seemlessly let me refer to columns named in
the long style just using id?

Thanks

 


------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing 
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss
Christian Schwartze | 11 Jun 11:27
Favicon

Call a function in a schema

Dear sqlobject users,
 
Is it possible to call functions with func() in a postgresql schema other than the public one? I am using SQLObject 0.10.
Thanks a lot for your help!
 
Regards,
Christian.
------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing 
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss
Sam's Lists | 11 Jun 06:37

Quoting reserved column names...

So I keep humming along on this upgrade of someone else's code from old versions of SQLObject and Mysql to the current SQLObject and MySQL 5...

The current problem is that I have a table with the column name 'condition' which apparently is not a reserved word in MySQL 4.0 but is a reserved word in 5.0.

When SQLObject translates its stuff to sql it does not put quotes
around the column names.  If it only would everything would work fine.

I could rename the column, but the word is used a lot in the program
in different ways, so it will get confusing to make sure I only change
the right ones .

Is there a way to force SQLObject to quote it properly?

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing 
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss
Sam's Lists | 11 Jun 03:04

longId=True handling...

I posted this on the TurboGears mailing list but now I'm posting it here in hopes for more help.

Essentially I am upgrading from SQLObject 0.7.1dev_r1653 and MySQL 4.x something to MySQL 5 something and SQLObject 0.10.6

I have this very complicated legacy TurboGears application that I'm
tasked with upgrading to 1.0.8 which has laid stagnant since the days
of early .99 series.

The original author used the following a lot in his table definitions:

class sqlmeta:
        style = MixedCaseStyle(longID=True)

What this means is that instead of the id column being named 'id' it
takes on the name of the table...so if the table is called EventQueue,
the id column name is EventQueueID.

So far so good....but here's where it gets weird.

It appears that under the really old versions of TurboGears one could
refer to this EventQueueID as just .id and everything would work the
way you want it to.  (This appears to only be done in the app under
kid templates).

But now, under TG 1.0.8/the latest version of SQLObject that doesn't work.  Either I have to rename the
column to id or I have to refer to it as EventQueueID.

How can I make sqlObject seemlessly let me refer to columns named in
the long style just using id?

Thanks


------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing 
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss
Oleg Broytmann | 6 Jun 00:24
X-Face
Favicon

Vacation

Hello! I'm leaving the town for a vacation. Will be back at June 20. Please
help each other.

Oleg.
--

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

------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises 
looking to deploy the next generation of Solaris that includes the latest 
innovations from Sun and the OpenSource community. Download a copy and 
enjoy capabilities such as Networking, Storage and Virtualization. 
Go to: http://p.sf.net/sfu/opensolaris-get
Herwig Hochleitner | 5 Jun 23:20

transactions; cache sync behavior; sqlite3 relatet?

Hi!

Attached is a small code snippet highlighting some strange behavior.
It outputs:

Writing 'connection_val' to connection foo
Value of transaction foo: 'init'
Writing 'transaction_val' to transaction foo
Value of connection foo: 'connection_val'

Instead of the expected:

Writing 'connection_val' to connection foo
Value of transaction foo: 'connection_val'
Writing 'transaction_val' to transaction foo
Value of connection foo: 'connection_val'

Is this behavior intentional? (ie can I rely on it)
Is is sqlite3 related? (right now I can't test it on another DB)

How should I fix this?
.expire()? .sync()?
Invalidate the transaction's cache?

Caching behavior in sqlobject looks like some can worms to me.

regards
Herwig Hochleitner

Attachment (adhoc_test_transactions.py): text/x-python, 724 bytes
------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises 
looking to deploy the next generation of Solaris that includes the latest 
innovations from Sun and the OpenSource community. Download a copy and 
enjoy capabilities such as Networking, Storage and Virtualization. 
Go to: http://p.sf.net/sfu/opensolaris-get
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Gmane