Oleg Broytman | 7 Oct 19:42
X-Face
Picon
Favicon

Re: SQLObject

Hello!

   Please write to the mailing list.

On Wed, Oct 07, 2009 at 04:21:50PM +0100, Chris Wood wrote:
> My database already contains intermediate tables of many:many relationships,

   Many-to-many relations in SQLObject are created using two RelatedJoin's.
Explicit intermediate tables are possible, too:

http://sqlobject.org/FAQ.html#how-can-i-define-my-own-intermediate-table-in-my-many-to-many-relationship

   The example in the FAQ uses SQLRelatedJoin's. The difference is that
RelatedJoin attributes return a list of rows (SQLObject instances) where
SQLRelatedJoin attributes return a SelectResults instance which you can
iterate over.

Oleg.
--

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

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
Jason Culverhouse | 8 Oct 20:30
Favicon

"Memory Leak" in sqlobject/cache.py

Hi,
I'm using an older copy of SQLObject but sqlobject/cache.py hasn't  
really changed in 2 years, so this applies to current and past versions.

I operate a website that runs around 4million requests a day through  
an application using SQLObject.
At about mid day I end up with large amount of weakref objects and  
slowing response times.

Top 6 objects in memory:
2887448 <type 'weakref'>
  209963 <type 'dict'>
   68189 <type 'tuple'>
   45584 <type 'weakproxy'>
   45584 <class 'sqlobject.main.SQLObjectState'>
   45584 <class 'sqlobject.declarative.sqlmeta'>

These objects are from the CacheFactory.expiredCache dictionary that  
holds weak references to SQLObject instances by id.  Some of these  
dictionaries reach ~1.5 million keys, each SQLObject.get() request has  
to look into this dictionary which results in an access slowdown and  
memory growth. When the object behind the weak reference is collected,  
a weakref with a dead object is left in the cache, In my case this is  
a memory leak.

Any comments or improvements on this method are appreciated.

There are lots of ways to solve this problem but I think this is the  
least disruptive.   Weakref callbacks can't be used because the  
"release" callback happens in the cull method.
(Continue reading)

Oleg Broytman | 8 Oct 21:04
X-Face
Picon
Favicon

Re: "Memory Leak" in sqlobject/cache.py

On Thu, Oct 08, 2009 at 11:30:51AM -0700, Jason Culverhouse wrote:
> I do 2 things in the cull method
> 1 - cull dead weak references out of the expiredCache.
> 2 - avoid placing dead weak references into the expiredCache

   Looks good. I will try it and apply it.

Oleg.
--

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

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
Oleg Broytman | 9 Oct 17:29
X-Face
Picon
Favicon

Re: "Memory Leak" in sqlobject/cache.py

On Thu, Oct 08, 2009 at 11:30:51AM -0700, Jason Culverhouse wrote:
> I do 2 things in the cull method
> 1 - cull dead weak references out of the expiredCache.
> 2 - avoid placing dead weak references into the expiredCache

   Works fine. I applied it and committed in the revisions 4028-4030
(branches 0.10, 0.11 and the trunk). Thank you very much!

Oleg.
--

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

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
Oleg Broytman | 12 Oct 19:20
X-Face
Picon
Favicon

SQLObject 0.12.0b1

Hello!

I'm pleased to announce version 0.12.0b1, the first beta release of the
upcoming branch 0.12 of SQLObject.

What is SQLObject
=================

SQLObject is an object-relational mapper.  Your database tables are described
as classes, and rows are instances of those classes.  SQLObject is meant to be
easy to use and quick to get started with.

SQLObject supports a number of backends: MySQL, PostgreSQL, SQLite,
Firebird, Sybase, MSSQL and MaxDB (also known as SAPDB).

Where is SQLObject
==================

Site:
http://sqlobject.org

Development:
http://sqlobject.org/devel/

Mailing list:
https://lists.sourceforge.net/mailman/listinfo/sqlobject-discuss

Archives:
http://news.gmane.org/gmane.comp.python.sqlobject

(Continue reading)

Lutz Steinborn | 13 Oct 08:52
Picon

show/log query

Good morning,

is there a way to log the query that SQLObject generates ?

example (maybe stupid):

result = MyTable.get(1)
logging.debug('%s' % result.print_sql_query())

or without execution

logging.debug('%s' % MyTable.get(1).return_only_query_as_string())

Kindly regards
Lutz

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
Simon Cross | 13 Oct 09:41
Picon

Re: show/log query

On Tue, Oct 13, 2009 at 8:52 AM, Lutz Steinborn <l.steinborn <at> 4c-ag.de> wrote:
> is there a way to log the query that SQLObject generates ?

See http://www.sqlobject.org/SQLObject.html#dbconnection-database-connections.

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
Oleg Broytman | 13 Oct 09:45
X-Face
Picon
Favicon

Re: show/log query

On Tue, Oct 13, 2009 at 08:52:48AM +0200, Lutz Steinborn wrote:
> is there a way to log the query that SQLObject generates ?

   Sure. You can turn on debug flag in DB URI or connection:

__connection__ = 'sqlite:///path/to/db?debug=1'

   With debug turned on SQLObject prints queries to stdout, so you can
redirect the stdout of your program or sys.stdout. You can also redirect
this printing to stderr:

__connection__ = 'sqlite:///path/to/db?debug=1&loglevel=stderr'

   To use logging instead of printing you have to name both the logger and
the loglevel:

__connection__ = 'sqlite:///path/to/db?logger=sqllog&loglevel=debug'

   'logger' is any log name, see
http://sqlobject.org/SQLObject.html#dbconnection-database-connections for
details on configuring logging. 'loglevel' in this case must be a logging
method (debug, info, warning, error, critical, exception).

   SQLObject (DBConnection, actually) emits a number of logging messages,
see method printDebug at
http://svn.colorstudy.com/SQLObject/trunk/sqlobject/dbconnection.py

Oleg.
--

-- 
     Oleg Broytman            http://phd.pp.ru/            phd <at> phd.pp.ru
(Continue reading)

Lutz Steinborn | 13 Oct 10:11
Picon

Re: show/log query

On Tue, 13 Oct 2009 11:45:36 +0400
Oleg Broytman <phd <at> phd.pp.ru> wrote:

> On Tue, Oct 13, 2009 at 08:52:48AM +0200, Lutz Steinborn wrote:
> > is there a way to log the query that SQLObject generates ?
> 
>    Sure. You can turn on debug flag in DB URI or connection:
But this gives me all queries. What I wan't is a possibility to log only on
query.
We have a lot of queries so its hard to find the right query in the logfiles.
Some times you will see only a query with special parameters. Its not only
interesting for logging its nice to have this for evidence.

Is where a way to do this ?

Regards 
Lutz

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
Oleg Broytman | 13 Oct 10:31
X-Face
Picon
Favicon

Re: show/log query

On Tue, Oct 13, 2009 at 10:11:13AM +0200, Lutz Steinborn wrote:
> On Tue, 13 Oct 2009 11:45:36 +0400
> Oleg Broytman <phd <at> phd.pp.ru> wrote:
> > On Tue, Oct 13, 2009 at 08:52:48AM +0200, Lutz Steinborn wrote:
> > > is there a way to log the query that SQLObject generates ?
> > 
> >    Sure. You can turn on debug flag in DB URI or connection:
> But this gives me all queries. What I wan't is a possibility to log only on
> query.

   You can override .get() or .select() or any other method in the
SQLObject class you are interesting in, lower logging level, call the
overridden method and restore logging level. For example, configure
logging at the INFO level, configure SQLObject at the debug level;
debug logging is not emitted at the INFO level; in your overridden methods
lower logging level to DEBUG and then back to INFO.

Oleg.
--

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

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference

Gmane