[Zope-DB] newbie--Putting Zope data into MSSQL

Tuttle, Gene cetuttle at rottlundhomes.com
Wed Jun 9 16:25:58 EDT 2004


Zsql methods are your answer.

check
http://zope.org/Documentation/Books/ZopeBook/2_6Edition/RelationalDatabases.
stx
<http://zope.org/Documentation/Books/ZopeBook/2_6Edition/RelationalDatabases
.stx> 

here is a sample zsql method obtained by using fpt port on zope to download.
by using a form to gather the data then passing the REQUEST object to the
following method data is inserted into the database.




DTML method to get data and update database
****************************************************************************
**************************************************************************
<dtml-var standard_html_header>

<!-- Check to see if the form has been submitted -->
          <dtml-if submit>
                  <dtml-try>
                                <dtml-call
"AddBuyerForm.validate_all_to_request(REQUEST)">
                                <dtml-except FormValidationError>
                                        <ul>
                                        <dtml-in "error_value.errors">
                                           <li>
                                           <dtml-var
"field.get_value('title')">:
                                           <dtml-var error_text>
                                           </li>
                                        </dtml-in>
                                        </ul>
                                <dtml-else>
                                <!-- Update the database with the new values
-->
                                        <dtml-call "add_buyer(REQUEST)">
<!-- this calles the sql method to insert the data into the database --->

                        </dtml-try>
                  </dtml-if>

<!-- Show the header of the form, using 'Form action' and 'Form method' from
settings
                (form action="..." method="...">)
        --->
<dtml-var  "AddBuyerForm.header()">
<form action=addbuyer>

<table border="0">

<!--- get a list of all the fields in the form --->
<dtml-in "AddBuyerForm.get_fields()">

<!--- rename each sequence item to field so they can be used more easily
--->
<dtml-let field=sequence-item>

<tr>
<td><dtml-var "field.get_value('title')"></td>
<td><dtml-var "field.render()"></td>
</tr>

</dtml-let>
</dtml-in>

<tr>
<td><input type="submit" value="Submit" name="submit"></td>
</tr>

</table>

<dtml-var "AddBuyerForm.footer()">

<dtml-var standard_html_foo
****************************************************************************
**************************************************************************


Data below was obtained from ZOPE  by using ftp 
this is the add_buyer method
****************************************************************************
**************************************************************************
<params>buyer_name_last buyer_name_first buyer_name_mi buyer_phone_home
buyer_phone_work buyer_phone_cell  buyer_email_primary buyer_address_street
buyer_address_city buyer_address_state buyer_address_zip </params>
insert into buyer
(
buyer_id,
buyer_name_last,
buyer_name_first,
buyer_name_mi,
buyer_phone_home,
buyer_phone_work,
buyer_phone_cell,
buyer_email_primary,
buyer_address_street,
buyer_address_city,
buyer_address_state,
buyer_address_zip)
Values(
nextval('buyer_buyer_id_seq')
<dtml-sqlvar buyer_name_first type="string">,
<dtml-sqlvar buyer_name_last type="string">,
<dtml-sqlvar buyer_name_mi type="string">,
<dtml-sqlvar buyer_phone_home type="string">,
<dtml-sqlvar buyer_phone_work type="string">,
<dtml-sqlvar buyer_phone_cell type="string">,
<dtml-sqlvar buyer_email_primary type="string">,
<dtml-sqlvar buyer_address_street type="string">,
<dtml-sqlvar buyer_address_city type="string">,
<dtml-sqlvar buyer_address_state type="string">,
<dtml-sqlvar buyer_address_zip type="string">
)
****************************************************************************
**************************************************************************

-----Original Message-----
From: Justin M. Keyes [ mailto:m9u35 at yahoo.com <mailto:m9u35 at yahoo.com> ]
Sent: June 09, 2004 3:14 PM
To: zope-db list
Subject: [Zope-DB] newbie--Putting Zope data into MSSQL


Hi,
I've set up the ZODBCDA and successfully *pulled* data from MSSQL using an Z
SQL query. But, I do not know how to *put* Zope data into the MSSQL
database.
I'm very new to databases--does SQL have commands to "push" data?  Stupid
question I'm sure...

I've read that ZODB can export itself to an XML file and then I can parse it
from there.  Is that the only way to get data from ZODB, or can I somehow
use
the ZODBCDA for my purpose?

Thanks so much.

Justin


       
               
__________________________________
Do you Yahoo!?
Friends.  Fun.  Try the all-new Yahoo! Messenger.
http://messenger.yahoo.com/ <http://messenger.yahoo.com/> 

_______________________________________________
Zope-DB mailing list
Zope-DB at zope.org
http://mail.zope.org/mailman/listinfo/zope-db
<http://mail.zope.org/mailman/listinfo/zope-db> 


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.zope.org/pipermail/zope-db/attachments/20040609/3fa898f2/attachment.html


More information about the Zope-DB mailing list