On 2/4/11 10:09 AM, Sibylle Koczian wrote:
> Hello,
>
> I just stumbled on the fact that I always have to use the right
> placeholder for my database module when I put parameters into my SQL.
> Dabo doesn't seem to unify them or anything. It's probably better like
> this, because not all database modules support named parameters and it
> would be a pity to lose them for all cases. On the other hand SQL
> statements and especially WHERE clauses might be distributed about the
> application, ui modules included, which makes changing the database more
> laborious.
>
> So I think this should be clearly documented, but I didn't find any
> relevant statement in the documentation.
>
> Did I just not find it or isn't it there?

FYI there's some minimal support for using ? as the placeholder for all 
backends. If 
you explicitly set UserSQL, the ?'s will get converted to whatever placeholder 
the 
current backend uses.

This allowed me to have this type of code run with both MySQL and SQLite (one 
uses 
"?", the other uses "%s", and I suppose the fact that I can't remember which is 
a 
good thing):

def getCustName(cust_id):
   cur = biz.getTempCursor("select name from customers where id=?", (cust_id,))
   try:
     return cur.Record.name
   except dException.NoRecordsException:
     return None

Paul
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: http://leafe.com/archives/byMID/[email protected]

Reply via email to