[Zope-DB] sql query works in database connector but not in ZSQL method

robert rottermann robert at redcor.ch
Wed Jan 17 12:19:30 EST 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Charlie Clark schrieb:
> Am 17.01.2007, 17:57 Uhr, schrieb robert rottermann <robert at redcor.ch>:
> 
>> I of course can send them into the interface as integer, but the
>> procedure is called with a sting (at least the error suggests that)
>> - -->{call selectVertexProperties('1')}' at line 1", 6088)
> 
> Remember you can use bound parameters with our DA so you don't have to
> worry about type conversion. This is not the case if you use query!!!
> 
> What is the exact code for your ExternalMethod?
> 
> Charlie
> 
> 

sorry to sound thick: how do I execute a query without calling
db.query(..) ?


this is what I do without using zope:
- -------------------------------------
def findUser(username):
    query = "CALL selectVertexIdFromLogin('%s', @id, @error1);" \
            "CALL selectVertexProperties(@id, @error2)" % username
    cursor.execute(query)
    cursor.nextset()
    print cursor.fetchall()

this is what I try to do in a method in a Zope product of ours:
- ---------------------------------------------------------------
    def getUserDataById(self, userid=''):
        "return base user data for user. if userid is not given use
looged in user"
        db = self.redscout_tool.scout_connection()
        sql_delimiter = self.sql_delimiter
        if not userid:
            userid = self.portal_membership.getAuthenticatedMember().getId()
        query = "CALL selectVertexIdFromLogin('%s', @id, @error); select
@error, @id" % userid
        result = db.query((query).replace(';', sql_delimiter))
        if result:
            result = result[1][0]
            error = int(result[0])
            if error:
                "handle error"
                return 'fehler'
            else:
                dbid = int(result[1])
                query =  "CALL selectVertexProperties(%s, @error2)" % dbid
- ----- problem>> result = db.query((query).replace(';', sql_delimiter))
                return result


robert
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)
Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org

iD8DBQFFrlqiGaryJ0T9kUYRAjpWAJoDM/VSPqawNs/+pM0IMT0/sUAS9wCdHt8B
5FZsyOj4J1QkcEXGDtcbUoU=
=Jq2W
-----END PGP SIGNATURE-----


More information about the Zope-DB mailing list