SunQuest
 
       Zope
  Home arrow Zope arrow Page 4 - Zope And MySQL
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Actuate Whitepapers 
VeriSign Whitepapers 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ZOPE

Zope And MySQL
By: icarus, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 26
    2002-04-10

    Table of Contents:
  • Zope And MySQL
  • Making The Connection
  • Adapting To The Environment
  • The Magic Of The Movies
  • Visiting The Box Office
  • Adding Things Up
  • Submitting To The King
  • Erasing The Past
  • Of Methods And Madness

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
    IBM developerWorks
     
    ADVERTISEMENT

    At the virtual BlackBerry Technical Seminar 2008, you can ask your development questions directly of Research In Motion® (RIM) experts, and take advantage of learning opportunities designed uniquely for BlackBerry solution developers. Register Today!

    Zope And MySQL - The Magic Of The Movies


    (Page 4 of 9 )

    With Zope and MySQL now talking to each other, it's time to start actually doing something with them. Here's the MySQL table I'll be using throughout this article - it stores information on my DVD collection.

    CREATE TABLE dvd ( id int(10) unsigned DEFAULT '0' NOT NULL, title varchar(255) NOT NULL, cast varchar(255) NOT NULL, director varchar(255) NOT NULL, genre varchar(255) NOT NULL ); INSERT INTO dvd VALUES ( '1', 'Don't Say A Word', 'Michael Douglas, Sean Bean and Brittany Murphy', 'Gary Fleder', 'Suspense'); INSERT INTO dvd VALUES ( '2', 'Captain Corelli's Mandolin', 'Penelope Cruz and Nicolas Cage', 'John Madde', 'Romance');
    Now, the second step in getting Zope to communicate with this database involves creating an instance of the Z MySQL Database Connection object. You can create one of these via Zope's management interface; when you do, you'll see something like this:



    At this point, it's necessary to specify a database connection string, so that Zope can open a connection to the database. This string is usually of the form:

    database[@host[:port]] [user [password [unix_socket]]]
    So, if I wanted to set up a connection to the database "mystuff" for user "john" with password "secret", my connection string would look like this:

    mystuff john secret
    Once you've created the Connection object, you can test it via the Test function that appears within the Zope management interface. This function allows you to execute any SQL query on the database, and returns the result to you instantly. Try executing the query

    SELECT * FROM dvd
    and see what happens. If your screen fills up with data, it means that your database connection is working just fine.

    Once a Database Connection object has been created, it's possible to instantiate Z SQL Methods to execute queries via this connection (I'll be doing this over the next few pages).

    More Zope Articles
    More By icarus, (c) Melonfire


     

       

    ZOPE ARTICLES

    - Creating Zope Products
    - Plone Content Types With Archetypes
    - Flat User Management in Zope
    - Creating Basic Zope Applications
    - Getting started with Zope for Linux and Sola...
    - ZPT Basics (part 4)
    - ZPT Basics (part 3)
    - ZPT Basics (part 2)
    - ZPT Basics (part 1)
    - Exception Handling In DTML
    - DTML Basics (part 4)
    - DTML Basics (part 3)
    - DTML Basics (part 2)
    - DTML Basics (part 1)
    - Using Zope With Apache

    IBM developerWorks




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway