[Zope] ZSQL Method Question

Jonathan dev101 at magma.ca
Mon Jul 17 13:36:26 EDT 2006


when you do an insert with a ZSQL method you do not get back any info from mysql, you need to do a subsequent search to get 'autogenerated' columns.  So do your insert, then do an ZSQL search.  The search returns a 'Results' object which has several methods you can use to get at the search results.

In a python script try something like:

rstat=context.UserActivity.SQL_SearchEvents(userId='111')   #substitute your own zsql search
print 'rstat= ', rstat
print 'rstat.names= ',rstat.names()
print 'rstat.tuples= ',rstat.tuples()
print 'rstat.asRDB= ',rstat.asRDB()
print 'rstat.data_dictionary= ',rstat.data_dictionary()
print 'rstat.dictionaries= ',rstat.dictionaries()



hth

Jonathan

  ----- Original Message ----- 
  From: Benjamin Menking 
  To: zope at zope.org 
  Sent: Monday, July 17, 2006 1:01 PM
  Subject: [Zope] ZSQL Method Question


  New to python/Zope, old-timer on PHP....

  I'm using MySQL and a ZSQL method to insert data into the database.  ex:

      insert into org (org_name, org_phone) values ('x', 'y')

  What I'm trying to figure out is that org_id (also part of the org table, but not specified in the sql statement) is an auto_increment primary key field and in PHP I can use mysql_insert_id() to find out what org_id was set to after the mysql_query() call.

  Is there a way to retrieve that value with ZSQL method, or must I use some other mechanism?

  Thanks!

-- 

Ben Menking RHCE
IT Security Consulting
(864) 420-5603
(864) 751-1638 fax

IT and Business Solutions

------------------------------------------------------------------------------


  _______________________________________________
  Zope maillist  -  Zope at zope.org
  http://mail.zope.org/mailman/listinfo/zope
  **   No cross posts or HTML encoding!  **
  (Related lists - 
   http://mail.zope.org/mailman/listinfo/zope-announce
   http://mail.zope.org/mailman/listinfo/zope-dev )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.zope.org/pipermail/zope/attachments/20060717/bed8abda/attachment.htm


More information about the Zope mailing list