MySQL connectivity in Zope/Plone
Basics how to connect MySQL from Zope and Plone.
You already have a MySQL database and want to show its data in Plone? Well thats a simple task, read here how.
You're a PHP guy first time on Plone and like start a new project?
You want to use MySQL tables to store your data? Well, so in 90% of all use-cases you should not: Learn how to do it the object-oriented Plonish way! (Hint: use Archetypes and ArchGenXML)
First: All software you need is on sourceforge mysql-python project
So here the basic steps:
- Install
mysql-pythonto your Python. Most linux-distributions are offering this packaged. If you're on windows there is a .exe download. Follow the links and documentation at sourceforge. - Download
zmysqldafrom sourceforge and extract it to your Products directory. - Restart Zope, login as manager, go to your Plone ZMI.
- Add a
Z MySQL Database Connectionin ZMI 'Add'-drop-down. Follow the verbose instructions how to connect you database. - Add a
Z SQL Method using the connectionand write in your query.
Thats all, now you have the connection and you can execute querys from within Plone using the test tab.
For more and detailled info about using the connection read Zope Book: Relational Database Connectivity
You can use Page-Templates instead of DTML as well. Follow the Plone way of page templates to make result display look good:
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
lang="en"
metal:use-macro="here/main_template/macros/master"
i18n:domain="plone">
<body>
<metal:main fill-slot="main">
<tal:main-macro metal:define-macro="main"
tal:define="results here/your_sql_methods_id">
FILL IN YOUR XHTML/TAL TO DISPLAY RESULTS
</tal:main>
</metal:main>
</body>
</html>