sqlobject-discuss Mailing List for SQLObject (Page 24)
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
You can subscribe to this list here.
| 2003 |
Jan
|
Feb
(2) |
Mar
(43) |
Apr
(204) |
May
(208) |
Jun
(102) |
Jul
(113) |
Aug
(63) |
Sep
(88) |
Oct
(85) |
Nov
(95) |
Dec
(62) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2004 |
Jan
(38) |
Feb
(93) |
Mar
(125) |
Apr
(89) |
May
(66) |
Jun
(65) |
Jul
(53) |
Aug
(65) |
Sep
(79) |
Oct
(60) |
Nov
(171) |
Dec
(176) |
| 2005 |
Jan
(264) |
Feb
(260) |
Mar
(145) |
Apr
(153) |
May
(192) |
Jun
(166) |
Jul
(265) |
Aug
(340) |
Sep
(300) |
Oct
(469) |
Nov
(316) |
Dec
(235) |
| 2006 |
Jan
(236) |
Feb
(156) |
Mar
(229) |
Apr
(221) |
May
(257) |
Jun
(161) |
Jul
(97) |
Aug
(169) |
Sep
(159) |
Oct
(400) |
Nov
(136) |
Dec
(134) |
| 2007 |
Jan
(152) |
Feb
(101) |
Mar
(115) |
Apr
(120) |
May
(129) |
Jun
(82) |
Jul
(118) |
Aug
(82) |
Sep
(30) |
Oct
(101) |
Nov
(137) |
Dec
(53) |
| 2008 |
Jan
(83) |
Feb
(139) |
Mar
(55) |
Apr
(69) |
May
(82) |
Jun
(31) |
Jul
(66) |
Aug
(30) |
Sep
(21) |
Oct
(37) |
Nov
(41) |
Dec
(65) |
| 2009 |
Jan
(69) |
Feb
(46) |
Mar
(22) |
Apr
(20) |
May
(39) |
Jun
(30) |
Jul
(36) |
Aug
(58) |
Sep
(38) |
Oct
(20) |
Nov
(10) |
Dec
(11) |
| 2010 |
Jan
(24) |
Feb
(63) |
Mar
(22) |
Apr
(72) |
May
(8) |
Jun
(13) |
Jul
(35) |
Aug
(23) |
Sep
(12) |
Oct
(26) |
Nov
(11) |
Dec
(30) |
| 2011 |
Jan
(15) |
Feb
(44) |
Mar
(36) |
Apr
(26) |
May
(27) |
Jun
(10) |
Jul
(28) |
Aug
(12) |
Sep
|
Oct
|
Nov
(17) |
Dec
(16) |
| 2012 |
Jan
(12) |
Feb
(31) |
Mar
(23) |
Apr
(14) |
May
(10) |
Jun
(26) |
Jul
|
Aug
(2) |
Sep
(2) |
Oct
(1) |
Nov
|
Dec
(6) |
| 2013 |
Jan
(4) |
Feb
(5) |
Mar
|
Apr
(4) |
May
(13) |
Jun
(7) |
Jul
(5) |
Aug
(15) |
Sep
(25) |
Oct
(18) |
Nov
(7) |
Dec
(3) |
| 2014 |
Jan
(1) |
Feb
(5) |
Mar
|
Apr
(3) |
May
(3) |
Jun
(2) |
Jul
(4) |
Aug
(5) |
Sep
|
Oct
(11) |
Nov
|
Dec
(62) |
| 2015 |
Jan
(8) |
Feb
(3) |
Mar
(15) |
Apr
|
May
|
Jun
(6) |
Jul
|
Aug
(6) |
Sep
|
Oct
|
Nov
|
Dec
(19) |
| 2016 |
Jan
(2) |
Feb
|
Mar
(2) |
Apr
(4) |
May
(3) |
Jun
(7) |
Jul
(14) |
Aug
(13) |
Sep
(6) |
Oct
(2) |
Nov
(3) |
Dec
|
| 2017 |
Jan
(6) |
Feb
(14) |
Mar
(2) |
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
(4) |
Nov
(3) |
Dec
|
| 2018 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2019 |
Jan
|
Feb
(1) |
Mar
|
Apr
(44) |
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
(1) |
| 2020 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
(1) |
| 2021 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
(3) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2022 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
(1) |
| 2023 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
(1) |
Nov
(2) |
Dec
|
| 2024 |
Jan
|
Feb
|
Mar
|
Apr
(4) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
| 2025 |
Jan
|
Feb
(1) |
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
(2) |
|
From: Oleg B. <ph...@ph...> - 2011-08-30 16:03:54
|
Hello! I'm pleased to announce version 1.1.3, a bugfix release of branch 1.1 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 Download: http://pypi.python.org/pypi/SQLObject/1.1.3 News and changes: http://sqlobject.org/News.html What's New ========== Features & Interface -------------------- * Fixed a bug with Postgres - add quotes in "SET client_encoding" query. For a more complete list, please see the news: http://sqlobject.org/News.html Oleg. -- Oleg Broytman http://phdru.name/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
|
From: Oleg B. <ph...@ph...> - 2011-08-30 16:03:10
|
Hello! I'm pleased to announce version 1.0.3, a bugfix release of branch 1.0 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 Download: http://pypi.python.org/pypi/SQLObject/1.0.3 News and changes: http://sqlobject.org/News.html What's New ========== * Fixed a bug with Postgres - add quotes in "SET client_encoding" query. For a more complete list, please see the news: http://sqlobject.org/News.html Oleg. -- Oleg Broytman http://phdru.name/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
|
From: Mark <mar...@ya...> - 2011-08-25 02:36:06
|
Oleg Broytman <phd <at> phdru.name> writes: > It depends on what you really want. Functionally, your SQL and python > code do the same thing but in different ways. SQL code works on the > server side and doesn't update the client side; python code performs > concatenation on the client side and sends an UPDATE like that: Great thanks, it makes perfect sense. |
|
From: Oleg B. <ph...@ph...> - 2011-08-21 09:16:41
|
On Sat, Aug 20, 2011 at 11:15:20PM +0000, Mark wrote:
> How would I do this in SQLObject?
>
> UPDATE
> Table
> SET
> some_text = CONCAT(some_text, 'text')
> WHERE
> id = 57
>
> Is it just
>
> table = Table.get(57)
> table.some_text = table.some_text + "text"
It depends on what you really want. Functionally, your SQL and python
code do the same thing but in different ways. SQL code works on the
server side and doesn't update the client side; python code performs
concatenation on the client side and sends an UPDATE like that:
UPDATE table SET some_text = new_text WHERE id = 57
If you really want to call CONCAT or any other function do it in
SQLObject like this:
from sqlobject.sqlbuilder import Update, func
connection.query(
Update(Table.sqlmeta.table,
{'some_text': func.CONCAT(Table.q.some_text, 'text')},
Test.q.id==57))
You have to ask SQLObject to update the client side because
you updated the server side and you don't want python and SQL sides to
by desynchronized:
table.sync()
Oleg.
--
Oleg Broytman http://phdru.name/ ph...@ph...
Programmers don't die, they just GOSUB without RETURN.
|
|
From: Mark <mar...@ya...> - 2011-08-20 23:15:45
|
How would I do this in SQLObject?
UPDATE
Table
SET
some_text = CONCAT(some_text, 'text')
WHERE
id = 57
Is it just
table = Table.get(57)
table.some_text = table.some_text + "text"
|
|
From: Timo <tim...@gm...> - 2011-08-14 08:28:37
|
On 13-08-11 15:43, Timo wrote:
> Hello, sorry if I use the wrong terminology, I just started with
> SQLObject and databases in general.
>
> This is my current class:
> class Person(SQLObject):
> name = StringCol(notNone=True)
> father = StringCol(default='')
> mother = StringCol(default='')
Sorry about the fuzz, after some more searching and experimenting, I
came up with the following which seems to work fine:
class Person(SQLObject):
name = StringCol(notNone=True)
father = ForeignKey('Person', default=None)
mother = ForeignKey('Person', default=None)
p1 = Person(name='John')
print p1, p1.father, p1.mother
p2 = Person(name='Jane')
print p2, p2.father, p2.mother
p3 = Person(name='Jeff', father=p1, mother=p2)
print p3, p3.father, p3.mother
Cheers,
Timo
>
> This stores the names for the person's father and mother, but when I
> want to access their data, I need to fetch their names first and then
> lookup their objects from the database. What I actually want, is that
> father and mother are references to their own Person object. Is
> something like this possible? I read about SingleJoin/MultipleJoin,
> but it always references to another table.
>
> Cheers,
> Timo
|
|
From: Timo <tim...@gm...> - 2011-08-13 13:43:53
|
Hello, sorry if I use the wrong terminology, I just started with SQLObject
and databases in general.
This is my current class:
class Person(SQLObject):
name = StringCol(notNone=True)
father = StringCol(default='')
mother = StringCol(default='')
This stores the names for the person's father and mother, but when I want to
access their data, I need to fetch their names first and then lookup their
objects from the database. What I actually want, is that father and mother
are references to their own Person object. Is something like this possible?
I read about SingleJoin/MultipleJoin, but it always references to another
table.
Cheers,
Timo
|
|
From: Daniel F. <fet...@go...> - 2011-08-10 16:38:50
|
Have fun Oleg! Cheers, Daniel > Hi! I am taking a week off. > > Oleg. -- Psss, psss, put it down! - http://www.cafepress.com/putitdown |
|
From: Oleg B. <ph...@ph...> - 2011-08-09 15:43:45
|
Hi! I am taking a week off.
Oleg.
--
Oleg Broytman http://phdru.name/ ph...@ph...
Programmers don't die, they just GOSUB without RETURN.
|
|
From: Oleg B. <ph...@ph...> - 2011-08-08 13:17:12
|
Hello! I'm pleased to announce version 1.1.2, a bugfix release of branch 1.1 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 Download: http://pypi.python.org/pypi/SQLObject/1.1.2 News and changes: http://sqlobject.org/News.html What's New ========== Features & Interface -------------------- * A bug was fixed in SelectResults slicing that prevented to slice a slice (my_results[:20][1:5]). For a more complete list, please see the news: http://sqlobject.org/News.html Oleg. -- Oleg Broytman http://phdru.name/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
|
From: Oleg B. <ph...@ph...> - 2011-08-08 13:16:48
|
Hello! I'm pleased to announce version 1.0.2, a bugfix release of branch 1.0 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 Download: http://pypi.python.org/pypi/SQLObject/1.0.2 News and changes: http://sqlobject.org/News.html What's New ========== * A bug was fixed in SelectResults slicing that prevented to slice a slice (my_results[:20][1:5]). For a more complete list, please see the news: http://sqlobject.org/News.html Oleg. -- Oleg Broytman http://phdru.name/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
|
From: Simon L. <sl...@re...> - 2011-08-05 23:39:41
|
Thanks! Sorry, my email filter moved this into a hidden folder. I'll take a look :) Here's hoping -S -----Original Message----- From: Simon Cross [mailto:hod...@gm...] Sent: Thursday, July 21, 2011 1:32 AM To: Simon Laalo Cc: sql...@li... Subject: Re: [SQLObject] eagerly fetching joined objects Hi On Thu, Jul 21, 2011 at 2:07 AM, Simon Laalo <sl...@re...> wrote: > I'm currently trying to improve my DB performance by reducing the number of queries > and associated overhead while grabbing some SQLObjects from the DB. I would like > to have SQLObject fully populate the object graph for the objects I'm using since all > joined objects will be read every time this object is loaded. I encountered a similar need in one of my own projects and wrote a caching version of RelatedJoin that you could probably take ideas from for a caching version of MultipleJoin / ForeignKey. You can find the code at http://sutekh.svn.sourceforge.net/viewvc/sutekh/trunk/sutekh/sutekh/core/CachedRelatedJoin.py?revision=2873&view=markup. I considered contributing it back to SQLObject but it's a bit finicky to use -- one has to manually initialize the cache (see init_cache method) and then flush the cache (flush_cache) or just particular items (invalidate_cache_item) from within one's application as needed. Schiavo Simon |
|
From: Oleg B. <ph...@ph...> - 2011-07-25 08:04:07
|
On Mon, Jul 25, 2011 at 02:01:50AM -0300, Egor Sledov wrote: > I am trying to go through sqlbuilder Select example at http://sqlobject.org/SQLBuilder.html > > >>> select = Select(['name', 'age'], staticTables = ['person']) > >>> print cn.sqlrepr(select) > SELECT 'name', 'age' FROM person > > Why does sqlrepr put quotes around column names? Because Select doesn't treat strings as a special case and calls sqlrepr() on them. Strings should be probably special-cased. > Is it allowed to provide a list of string field names here or Select accepts only list of q-values now? Items is a list of SQLExpressions and you can get a static SQLExpression like this: from sqlobject.sqlbuilder import Select, const >>> select = Select([const.name, const.age], staticTables = ['person']) >>> print cn.sqlrepr(select) SELECT name, age FROM person Oleg. -- Oleg Broytman http://phdru.name/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
|
From: Egor S. <eg...@co...> - 2011-07-25 05:05:04
|
I am trying to go through sqlbuilder Select example at http://sqlobject.org/SQLBuilder.html >>> select = Select(['name', 'age'], staticTables = ['person']) >>> print cn.sqlrepr(select) SELECT 'name', 'age' FROM person Why does sqlrepr put quotes around column names? Is it allowed to provide a list of string field names here or Select accepts only list of q-values now? Thank you. |
|
From: Oleg B. <ph...@ph...> - 2011-07-21 17:36:03
|
On Thu, Jul 21, 2011 at 10:32:08AM +0200, Simon Cross wrote: > I encountered a similar need in one of my own projects and wrote a > caching version of RelatedJoin that you could probably take ideas from > for a caching version of MultipleJoin / ForeignKey. You can find the > code at http://sutekh.svn.sourceforge.net/viewvc/sutekh/trunk/sutekh/sutekh/core/CachedRelatedJoin.py?revision=2873&view=markup. > I considered contributing it back to SQLObject but it's a bit finicky > to use -- one has to manually initialize the cache (see init_cache It would be an interesting additions even if it's not suitable for the SQLObject core. I can add it to sqlobject/include if you document it and add an example or even better - a test. > method) and then flush the cache (flush_cache) or just particular SQLObject usually uses the word "clear" instead of flush. ;-) > items (invalidate_cache_item) from within one's application as needed. Populating/clearing the cache is too application-specific, it'd be hard to program a universal solution. But if there is a documented API for applications to use - no problem. Oleg. -- Oleg Broytman http://phdru.name/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
|
From: Simon C. <hod...@gm...> - 2011-07-21 08:32:19
|
Hi On Thu, Jul 21, 2011 at 2:07 AM, Simon Laalo <sl...@re...> wrote: > I'm currently trying to improve my DB performance by reducing the number of queries > and associated overhead while grabbing some SQLObjects from the DB. I would like > to have SQLObject fully populate the object graph for the objects I'm using since all > joined objects will be read every time this object is loaded. I encountered a similar need in one of my own projects and wrote a caching version of RelatedJoin that you could probably take ideas from for a caching version of MultipleJoin / ForeignKey. You can find the code at http://sutekh.svn.sourceforge.net/viewvc/sutekh/trunk/sutekh/sutekh/core/CachedRelatedJoin.py?revision=2873&view=markup. I considered contributing it back to SQLObject but it's a bit finicky to use -- one has to manually initialize the cache (see init_cache method) and then flush the cache (flush_cache) or just particular items (invalidate_cache_item) from within one's application as needed. Schiavo Simon |
|
From: Simon L. <sl...@re...> - 2011-07-21 00:22:30
|
Hi,
I'm currently trying to improve my DB performance by reducing the number of queries and associated overhead while grabbing some SQLObjects from the DB. I would like to have SQLObject fully populate the object graph for the objects I'm using since all joined objects will be read every time this object is loaded.
Here are prototypes for my objects
class A (SQLObject):
x = IntCol()
bees = MultipleJoin('B', joinColumn = 'a_id', orderBy='display_order')
cees = MultipleJoin('C', joinColumn = 'a_id', orderBy='display_order')
class B (SQLObject):
y = IntCol()
display_order = IntCol()
dees = MultipleJoin('D', joinColumn = 'b_id')
a = ForeignKey('A')
class C (SQLObject):
z = IntCol()
display_order = IntCol()
a = ForeignKey('A')
class D (SQLObject):
m = IntCol()
b = ForeignKey('B')
Is there any way using SQLObject I can reduce the number of queries from 1+(1+count_b) + (1+count_c) +(1+count_d)*count_b to something closer to 1 query?
Thanks in advance,
Simon
|
|
From: Timothy W. G. <tim...@si...> - 2011-07-20 09:37:21
|
No need to reply to this post. I changed the run configuration for my application in my IDE (Spyder) and all is well. (from 'current interpreter' to 'new dedicated interpreter') Thanks for your time. Tim On 20/07/2011 00:33, Timothy W. Grove wrote: > This probably has more to do with the IDE I'm just trying out (Spyder - > http://code.google.com/p/spyderlib/) rather than code errors as I > haven't experienced it before, but still, if anyway to prevent this > error comes to mind, I'd be glad to hear it. > > The first 'runfile' line below represents my application happily running > through Spyder. But after I close the application and run it for a > second time, python complains that my sqlobject classes are still in the > registry. Is there a way to ensure that this registry is clear once my > application is closed? This isn't really an issue when I'm running the > application on its own, but it is a pain while trying to edit it. > > Best regards, > Tim > > Python 2.7 (r27:82525, Jul 4 2010, 09:01:59) [MSC v.1500 32 bit > (Intel)] on win32 > Type "copyright", "credits" or "license" for more information. > >>> runfile(r'C:\DicSL\dicsl\dicsl.py', wdir=r'C:\DicSL\dicsl') > >>> runfile(r'C:\DicSL\dicsl\dicsl.py', wdir=r'C:\DicSL\dicsl') > UMD has deleted: gui.video_selection_window, dictionary.dicsl_meta, gui, > cfg, gui.photo_popup, gui.dialogs.opendictionary, > dictionary.explanatory, gui.dialogs.explanatory_dialogs, > gui.gloss_search_panel, gui.usage_window, dictionary.citation, > dictionary, gui.dialogs.about, error_logging, gui.video_panel, > gui.component_panel, dictionary.sentence, gui.mplayer_ctrl, > dictionary.gloss, gui.EnhancedStatusBar, gui.component_descriptions, > dictionary.component, gui.component_drop_panel, > gui.playback_rate_slider, dictionary.signentry, dictionary.dialect, > gui.mainframe, gui.location_panel, gui.component_type, > gui.dialogs.duplicatefile, gui.dialogs.newdictionary, dictionary.editor, > dictionary.lang_name, gui.dialogs.dialect_list, gui.dialogs > Traceback (most recent call last): > File "<stdin>", line 1, in<module> > File > "C:\Python27\lib\site-packages\spyderlib\widgets\externalshell\startup.py", > line 122, in runfile > execfile(filename, glbs) > File "C:\DicSL\dicsl\dicsl.py", line 11, in<module> > from gui import mainframe > File "gui\mainframe.py", line 22, in<module> > from dictionary.editor import Editor as DictionaryEditor > File "dictionary\editor.py", line 17, in<module> > from signentry import SignEntry, SignEntryUpdate > File "dictionary\signentry.py", line 46, in<module> > class SignEntry(SQLObject): > File > "C:\Python27\lib\site-packages\sqlobject-1.1.1-py2.7.egg\sqlobject\declarative.py", > line 92, in __new__ > cls.__classinit__(cls, new_attrs) > File > "C:\Python27\lib\site-packages\sqlobject-1.1.1-py2.7.egg\sqlobject\main.py", > line 813, in __classinit__ > classregistry.registry(sqlmeta.registry).addClass(cls) > File > "C:\Python27\lib\site-packages\sqlobject-1.1.1-py2.7.egg\sqlobject\classregistry.py", > line 91, in addClass > '__file__', '(unknown)'))) > ValueError: class SignEntry is already in the registry (other class is > <class 'dictionary.signentry.SignEntry'>, from the module > dictionary.signentry in dictionary\signentry.pyc; attempted new class is > <class 'dictionary.signentry.SignEntry'>, from the module > dictionary.signentry in dictionary\signentry.pyc) > > ------------------------------------------------------------------------------ > Magic Quadrant for Content-Aware Data Loss Prevention > Research study explores the data loss prevention market. Includes in-depth > analysis on the changes within the DLP market, and the criteria used to > evaluate the strengths and weaknesses of these DLP solutions. > http://www.accelacomm.com/jaw/sfnl/114/51385063/ > _______________________________________________ > sqlobject-discuss mailing list > sql...@li... > https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss > |
|
From: Timothy W. G. <tim...@si...> - 2011-07-19 23:34:17
|
This probably has more to do with the IDE I'm just trying out (Spyder - http://code.google.com/p/spyderlib/) rather than code errors as I haven't experienced it before, but still, if anyway to prevent this error comes to mind, I'd be glad to hear it. The first 'runfile' line below represents my application happily running through Spyder. But after I close the application and run it for a second time, python complains that my sqlobject classes are still in the registry. Is there a way to ensure that this registry is clear once my application is closed? This isn't really an issue when I'm running the application on its own, but it is a pain while trying to edit it. Best regards, Tim Python 2.7 (r27:82525, Jul 4 2010, 09:01:59) [MSC v.1500 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information. >>> runfile(r'C:\DicSL\dicsl\dicsl.py', wdir=r'C:\DicSL\dicsl') >>> runfile(r'C:\DicSL\dicsl\dicsl.py', wdir=r'C:\DicSL\dicsl') UMD has deleted: gui.video_selection_window, dictionary.dicsl_meta, gui, cfg, gui.photo_popup, gui.dialogs.opendictionary, dictionary.explanatory, gui.dialogs.explanatory_dialogs, gui.gloss_search_panel, gui.usage_window, dictionary.citation, dictionary, gui.dialogs.about, error_logging, gui.video_panel, gui.component_panel, dictionary.sentence, gui.mplayer_ctrl, dictionary.gloss, gui.EnhancedStatusBar, gui.component_descriptions, dictionary.component, gui.component_drop_panel, gui.playback_rate_slider, dictionary.signentry, dictionary.dialect, gui.mainframe, gui.location_panel, gui.component_type, gui.dialogs.duplicatefile, gui.dialogs.newdictionary, dictionary.editor, dictionary.lang_name, gui.dialogs.dialect_list, gui.dialogs Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Python27\lib\site-packages\spyderlib\widgets\externalshell\startup.py", line 122, in runfile execfile(filename, glbs) File "C:\DicSL\dicsl\dicsl.py", line 11, in <module> from gui import mainframe File "gui\mainframe.py", line 22, in <module> from dictionary.editor import Editor as DictionaryEditor File "dictionary\editor.py", line 17, in <module> from signentry import SignEntry, SignEntryUpdate File "dictionary\signentry.py", line 46, in <module> class SignEntry(SQLObject): File "C:\Python27\lib\site-packages\sqlobject-1.1.1-py2.7.egg\sqlobject\declarative.py", line 92, in __new__ cls.__classinit__(cls, new_attrs) File "C:\Python27\lib\site-packages\sqlobject-1.1.1-py2.7.egg\sqlobject\main.py", line 813, in __classinit__ classregistry.registry(sqlmeta.registry).addClass(cls) File "C:\Python27\lib\site-packages\sqlobject-1.1.1-py2.7.egg\sqlobject\classregistry.py", line 91, in addClass '__file__', '(unknown)'))) ValueError: class SignEntry is already in the registry (other class is <class 'dictionary.signentry.SignEntry'>, from the module dictionary.signentry in dictionary\signentry.pyc; attempted new class is <class 'dictionary.signentry.SignEntry'>, from the module dictionary.signentry in dictionary\signentry.pyc) |
|
From: Oleg B. <ph...@ph...> - 2011-07-19 13:35:06
|
On Tue, Jul 19, 2011 at 05:30:43PM +0400, Oleg Broytman wrote:
> Expired cache stores weak references. I.e. while the program is
> holding a (non-weak) reference to a row the cache will return the same
> row.
This is to prevent having two different (unsynchronized) objects to
represent the same row.
Oleg.
--
Oleg Broytman http://phdru.name/ ph...@ph...
Programmers don't die, they just GOSUB without RETURN.
|
|
From: Oleg B. <ph...@ph...> - 2011-07-19 13:31:01
|
On Tue, Jul 19, 2011 at 09:39:55AM -0300, Егор Следов wrote:
> It does not seem to work. When I set cache to 0 and debug to 1 in uri
>
> DB URI ('postgres://host/db?cache=0&debug=1')
>
> f = db.Person.get(5)
> print f.name
> f1 = db.Person.get(5)
> print f1.name
>
> I don't see second select to the database on second get.
> Apparently, the value is fetched from expiredCache.
>
> Any suggestions?
>
> Thank you.
Expired cache stores weak references. I.e. while the program is
holding a (non-weak) reference to a row the cache will return the same
row. The moment you free the last reference to the row the expired cache
is cleared and next time you will get a new row.
Get rid of f before getting f1:
del f
or
f = None
will do.
Oleg.
--
Oleg Broytman http://phdru.name/ ph...@ph...
Programmers don't die, they just GOSUB without RETURN.
|
|
From: Егор С. <eg...@co...> - 2011-07-19 12:43:08
|
It does not seem to work. When I set cache to 0 and debug to 1 in uri
DB URI ('postgres://host/db?cache=0&debug=1')
f = db.Person.get(5)
print f.name
f1 = db.Person.get(5)
print f1.name
I don't see second select to the database on second get.
Apparently, the value is fetched from expiredCache.
Any suggestions?
Thank you.
On 7/19/2011 7:34 AM, Oleg Broytman wrote:
> On Tue, Jul 19, 2011 at 12:21:32AM -0300, Егор Следов wrote:
>> I have a web application with two load-balanced webservers and a separate postgres database server.
>>
>> When SQLObject instance is updated, the update is processed randomly through either of the servers.
>> Sometimes user does the update on one server, and immediately opens object for reading on another.
>> So, if caching is on, it looks like database is not getting updated.
>>
>> If I turn caching off by setting sqlmeta.cacheValues to False, then call to each and every property issues a separate SQL select, and this slows everything down a lot.
>>
>> What would be the right approach to minimize number of selects on a single webpage?
>> Keeping cache on, but calling object.expire(), object.another.expire() after referencing any properties? Trying to lower cullFrequency parameter of cache?
>
> In SQLObject there are three ways of caching - attribute caching
> (governed by sqlmeta.cacheValues), row caching (governed by
> connection.cache), and update caching (governed by sqlmeta.lazyUpdates).
> What you probably want is to stop row caching - every time the programs
> fetches a row it asks the database, not the cache. So leave
> sqlmeta.cacheValues and sqlmeta.lazyUpdates alone (their default values
> are good for you) and set connection.cache.doCache=False. You can do it
> from DB URI ('postgres://host/db?cache=0'); if the program opens
> connection without an URI the parameter for PostgresConnection is
> cache=False.
>
> Oleg.
|
|
From: Oleg B. <ph...@ph...> - 2011-07-19 10:35:01
|
On Tue, Jul 19, 2011 at 12:21:32AM -0300, Егор Следов wrote:
> I have a web application with two load-balanced webservers and a separate postgres database server.
>
> When SQLObject instance is updated, the update is processed randomly through either of the servers.
> Sometimes user does the update on one server, and immediately opens object for reading on another.
> So, if caching is on, it looks like database is not getting updated.
>
> If I turn caching off by setting sqlmeta.cacheValues to False, then call to each and every property issues a separate SQL select, and this slows everything down a lot.
>
> What would be the right approach to minimize number of selects on a single webpage?
> Keeping cache on, but calling object.expire(), object.another.expire() after referencing any properties? Trying to lower cullFrequency parameter of cache?
In SQLObject there are three ways of caching - attribute caching
(governed by sqlmeta.cacheValues), row caching (governed by
connection.cache), and update caching (governed by sqlmeta.lazyUpdates).
What you probably want is to stop row caching - every time the programs
fetches a row it asks the database, not the cache. So leave
sqlmeta.cacheValues and sqlmeta.lazyUpdates alone (their default values
are good for you) and set connection.cache.doCache=False. You can do it
from DB URI ('postgres://host/db?cache=0'); if the program opens
connection without an URI the parameter for PostgresConnection is
cache=False.
Oleg.
--
Oleg Broytman http://phdru.name/ ph...@ph...
Programmers don't die, they just GOSUB without RETURN.
|
|
From: Егор С. <eg...@co...> - 2011-07-19 03:59:37
|
I have a web application with two load-balanced webservers and a separate postgres database server. When SQLObject instance is updated, the update is processed randomly through either of the servers. Sometimes user does the update on one server, and immediately opens object for reading on another. So, if caching is on, it looks like database is not getting updated. If I turn caching off by setting sqlmeta.cacheValues to False, then call to each and every property issues a separate SQL select, and this slows everything down a lot. What would be the right approach to minimize number of selects on a single webpage? Keeping cache on, but calling object.expire(), object.another.expire() after referencing any properties? Trying to lower cullFrequency parameter of cache? Thank you. |
|
From: Oleg B. <ph...@ph...> - 2011-07-13 01:55:26
|
On Wed, Jul 13, 2011 at 02:24:48AM +0100, Timothy W. Grove wrote: > Thanks again for your time and help. I've been able to identify the > index, but it doesn't appear that sqlite will allow such an index to be > dropped: > > raise OperationalError(ErrorMessage(e)) > sqlobject.dberrors.OperationalError: index associated with UNIQUE or > PRIMARY KEY constraint cannot be dropped > > Reading further, it looks like I'll have to do things the hard way: > http://stackoverflow.com/questions/1884787/how-do-i-drop-a-constraint-from-a-sqlite-3-6-21-table That's what I meant when I said "tricky SQL". Oleg. -- Oleg Broytman http://phdru.name/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |