Frank Conradie | 1 Dec 05:44
Favicon
Gravatar

sqlbuilder REPLACE

Forgive me if this has been discussed before, but I searched the 
archives without any success.

In sqlbuilder the "Replace" expression currently inherits from "Update", 
but in MySQL, according to their official docs, "REPLACE works exactly 
like INSERT", i.e. "REPLACE INTO ...". Thus it looks like it should 
rather inherit from "Insert" (just replacing the "INSERT" with "REPLACE").

I know very little about standard SQL, or other DB SQL, so I was 
wondering if this is universal?

- Frank

-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
Petr Jakeš | 4 Dec 22:50
Picon

refreshing atribute values, how?

I would like my atributes have actual values from the database in the time they are used (called).
Trying to googling and searching discussion goups for a while, I have found following solution:


class sqlmeta:
        cacheValues = False

Is this the only solution how to solve this problem?

Best regards

Petr Jakes

-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss
Oleg Broytmann | 4 Dec 23:01
X-Face
Picon
Favicon

Re: refreshing atribute values, how?

On Tue, Dec 04, 2007 at 10:50:58PM +0100, Petr Jake?? wrote:
> I would like my atributes have actual values from the database in the time
> they are used (called).
> Trying to googling and searching discussion goups for a while, I have found
> following solution:
> 
> class sqlmeta:
>         cacheValues = False
> 
> Is this the only solution how to solve this problem?

   Yes, this is the solution. But you have to understand now every
attribute access results in its own SELECT. I.e. attribute access =>
SQLObject => DB API driver => SQL backend => DB API driver => SQLObject =>
attribute value.

Oleg.
--

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

-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
Oleg Broytmann | 4 Dec 23:07
X-Face
Picon
Favicon

Re: sqlbuilder REPLACE

On Fri, Nov 30, 2007 at 08:44:18PM -0800, Frank Conradie wrote:
> In sqlbuilder the "Replace" expression currently inherits from "Update", 
> but in MySQL, according to their official docs, "REPLACE works exactly 
> like INSERT", i.e. "REPLACE INTO ...". Thus it looks like it should 
> rather inherit from "Insert" (just replacing the "INSERT" with "REPLACE").

   The syntax is (http://dev.mysql.com/doc/refman/4.1/en/replace.html):

REPLACE [LOW_PRIORITY | DELAYED]
     [INTO] tbl_name
     SET col_name={expr | DEFAULT}, ...

   That is, it's much more UPDATE (because of SET) than INSERT (that uses
a list of names and a list of values, not name/value pairs).

PS. Forgive me for not answering so long.

Oleg.
--

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

-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
Oleg Broytmann | 4 Dec 23:18
X-Face
Picon
Favicon

Re: SQLObject doesn't find Table on Ubuntu + MySQL 5.0.22

On Fri, Nov 30, 2007 at 10:10:45PM +0100, Nicolas Riedel wrote:
> ProgrammingError: Table 'ntime.Worktime' doesn't exist
[skip]
> class Worktime(SQLObject):

   This looks as if someone (TurboGears?) has replaced style. The default
style in SQLObject converts class names to lowercased table names but this
time it seems something prevents the conversion.

Oleg.
--

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

-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
Frank Conradie | 4 Dec 23:19
Favicon
Gravatar

Re: sqlbuilder REPLACE

Hi Oleg

I will have to disagree again - please read the page that you link to below carefully: "REPLACE works exactly like INSERT, except that if an old row in the table has the same value as a new row for a PRIMARY KEY or a UNIQUE index, the old row is deleted before the new row is inserted."

INSERT supports *exactly* the same 3 syntax options that REPLACE does, while UPDATE only overlaps the one syntax option, and not even fully (i.e. REPLACE does not accept a WHERE or LIMIT):

UPDATE [LOW_PRIORITY] [IGNORE] tbl_name SET col_name1=expr1 [, col_name2=expr2 ...] [WHERE where_condition] [ORDER BY ...] [LIMIT row_count] - Frank

Oleg Broytmann wrote:
On Fri, Nov 30, 2007 at 08:44:18PM -0800, Frank Conradie wrote:
In sqlbuilder the "Replace" expression currently inherits from "Update", but in MySQL, according to their official docs, "REPLACE works exactly like INSERT", i.e. "REPLACE INTO ...". Thus it looks like it should rather inherit from "Insert" (just replacing the "INSERT" with "REPLACE").
The syntax is (http://dev.mysql.com/doc/refman/4.1/en/replace.html): REPLACE [LOW_PRIORITY | DELAYED] [INTO] tbl_name SET col_name={expr | DEFAULT}, ... That is, it's much more UPDATE (because of SET) than INSERT (that uses a list of names and a list of values, not name/value pairs). PS. Forgive me for not answering so long. Oleg.
-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss
Petr Jakeš | 4 Dec 23:22
Picon

Re: refreshing atribute values, how?

On Tue, Dec 04, 2007 at 10:50:58PM +0100, Petr Jake?? wrote:
> I would like my atributes have actual values from the database in the time
> they are used (called).
> Trying to googling and searching discussion goups for a while, I have found
> following solution:
>
> class sqlmeta:
>         cacheValues = False
>
> Is this the only solution how to solve this problem?

  Yes, this is the solution. But you have to understand now every
attribute access results in its own SELECT. I.e. attribute access =>
SQLObject => DB API driver => SQL backend => DB API driver => SQLObject =>
attribute value.

I know the whole SQLObject machinery is running while I am using any of the SQLObject attribute. In my application two clients only are accessing to the database and they are working with the really small amount of data. So I guess the performance will not be an issue.

Or have I consider some other problem (bottle neck) than the performance of the script?

Petr
-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss
Oleg Broytmann | 4 Dec 23:23
X-Face
Picon
Favicon

Re: sqlbuilder REPLACE

On Tue, Dec 04, 2007 at 02:19:31PM -0800, Frank Conradie wrote:
> I will have to disagree again - please read the page that you link to 
> below carefully: "|REPLACE| works exactly like |INSERT|

   SQLObject is more interested in syntax. SET and name/value pairs make it
much more like UPDATE than INSERT.

Oleg.
--

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

-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
Oleg Broytmann | 4 Dec 23:25
X-Face
Picon
Favicon

Re: refreshing atribute values, how?

On Tue, Dec 04, 2007 at 11:22:29PM +0100, Petr Jake?? wrote:
> Or have I consider some other problem (bottle neck) than the performance of
> the script?

   No, performance is the only concern. If you are satisfied - no problem.

Oleg.
--

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

-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
Frank Conradie | 4 Dec 23:29
Favicon
Gravatar

Re: sqlbuilder REPLACE

Hi Oleg

I don't want to fight with you, but INSERT also supports SET:

INSERT [LOW_PRIORITY | DELAYED | HIGH_PRIORITY] [IGNORE]
    [INTO] tbl_name
    SET col_name={expr | DEFAULT}, ...

And here is the REPLACE syntax:

REPLACE [LOW_PRIORITY | DELAYED]
    [INTO] tbl_name
    SET col_name={expr | DEFAULT}, ...

In fact, both INSERT and REPLACE support the *exact same* 3 different syntaxes:

REPLACE/INSERT [LOW_PRIORITY | DELAYED]
    [INTO] tbl_name [(col_name,...)]
    VALUES ({expr | DEFAULT},...),(...),...

Or:

REPLACE/INSERT [LOW_PRIORITY | DELAYED]
    [INTO] tbl_name
    SET col_name={expr | DEFAULT}, ...

Or:

REPLACE/INSERT [LOW_PRIORITY | DELAYED]
    [INTO] tbl_name [(col_name,...)]
    SELECT ...

But UPDATE only has 1 syntax:

UPDATE [LOW_PRIORITY] [IGNORE] tbl_name
    SET col_name1=expr1 [, col_name2=expr2 ...]
    [WHERE where_condition]
    [ORDER BY ...]
    [LIMIT row_count]

I can also post code that proves this, although you can save me some time by just reading the 3 pages of MySQL documentation.

- Frank



Oleg Broytmann wrote:
On Tue, Dec 04, 2007 at 02:19:31PM -0800, Frank Conradie wrote:
I will have to disagree again - please read the page that you link to below carefully: "|REPLACE| works exactly like |INSERT|
SQLObject is more interested in syntax. SET and name/value pairs make it much more like UPDATE than INSERT. Oleg.
-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Gmane