[Zope3-dev] Re: What don't file-system-based developers need
Philipp von Weitershausen
philipp at weitershausen.de
Fri Feb 13 05:09:03 EST 2004
Jeffrey P Shell wrote:
> Would probably use them, but not always. I've become disillusioned with
> O-R Mapping, and there are definitely times when - NOT AS A SCRIPTER - I
> still need to use fairly plain SQL.
I understand that. O-R Mappings can be a bit overhead some time.
> I've been doing this in file system development in Zope 2 by doing:
>
> from Products.ZSQLMethods.SQL import SQL as SQLMethod
from zope.products.sqlscript.sqlscript import SQLScript
(that's if you're in philikon-movecontent-branch. in HEAD you'd do
from zope.app.content.sql import SQLScript)
> DBNAME = 'dbc' #name of Database Adapter
>
> class Frobnitz(...):
> listUpcomingShows = SQLMethod(
> 'listUpcomingShows', '', DBNAME,
> 'max_date=""',
> """ <SQL Method Code Here> """,
> )
Should work the same way with SQLScript.
> I'd like to have the latter, even if I don't have something akin to SQL
> Methods. I just want a [service|utility] that I can configure and then
> send SQL Statements to and get result objects back from.
Well, you can still talk to the SQL adapter (a utility) yourself::
from zope.app.interfaces.rdb import IZopeDatabaseAdapter
from zope.app.rdb import queryForResults
query = "SELECT %(columns)s FROM %(table)s" % parameter_dict
connection = zapi.getUtility(context, IZopeDatabaseAdapter, DBNAME)
result = queryForResults(connection, query)
SQLScript has the advantage that it can cache results just like SQLMethods.
> The DTML SQL tags are nice, but I could live without them.
They are supported by SQLScript.
I guess the answer to whether we have a file-system flavour of SQLScript
is "No, but you can use them from the file-system like SQLMethods back
in Zope 2"...
Philipp
More information about the Zope3-dev
mailing list