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. 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: 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: 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 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).
blog comments powered by Disqus |