~james-w/ubuntu/lucid/psycopg2/precise-backport

« back to all changes in this revision

Viewing changes to psycopg2da/README.txt

  • Committer: Bazaar Package Importer
  • Author(s): Fabio Tranchitella
  • Date: 2007-01-15 11:39:15 UTC
  • mfrom: (3.1.4 feisty)
  • Revision ID: james.westby@ubuntu.com-20070115113915-sxejh5ganrncld1x
Tags: 2.0.5.1-6
debian/zope-psycopgda2.dzproduct: requires Zope 2.9 or higher: previous
versions use python2.3 which is not supported anymore in psycopg.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
==========
 
2
psycopg2da
 
3
==========
 
4
 
 
5
This file outlines the basics of using Zope3 with PostgreSQL via PsycopgDA.
 
6
 
 
7
Installing PsycopgDA
 
8
--------------------
 
9
 
 
10
1. Check out the psycopg2da package into a directory in your
 
11
   PYTHONPATH.  INSTANCE_HOME/lib/python or Zope3/src is usually the
 
12
   most convenient place:
 
13
 
 
14
 
 
15
   svn co svn://svn.zope.org/repos/main/psycopg2da/trunk psycopg2da
 
16
 
 
17
 
 
18
2. Copy `psycopg2-configure.zcml` to the `package-includes` directory
 
19
   of your Zope instance.
 
20
 
 
21
 
 
22
Creating Database Connections
 
23
------------------------------
 
24
 
 
25
It is time to add some connections. A connection in Zope 3 is
 
26
registered as a utility.
 
27
 
 
28
3. Open a web browser on your Zope root folder (http://localhost:8080/
 
29
   if you use the default settings in zope.conf.in).
 
30
 
 
31
4. Click on the 'Manage Site' action on the right side of the
 
32
   screen. You should see a screen which reads 'Common Site Management
 
33
   Tasks'
 
34
 
 
35
5. Around the middle of that page, you should see a link named 'Add
 
36
   Utility'. Click on it.
 
37
 
 
38
6. Select 'Psycopg DA' and type in a name at the bottom of the page.
 
39
 
 
40
7. Enter the database connection string.  It looks like this:
 
41
 
 
42
     dbi://username:password@host:port/databasename
 
43
 
 
44
8. Click on the 'Add' button.
 
45
 
 
46
9. You should be on a page which reads 'Add Database Connection
 
47
   Registration'. There you can configure the permission needed to use
 
48
   the database connection, the name of the registration and the
 
49
   registration status. You can use any name for 'Register As' field,
 
50
   as long as it doesn't clash with an existing one. Choose a
 
51
   permission. Choose between 'Registered' and 'Active' for the
 
52
   'Registration Status'. Only one component of a kind can be 'Active'
 
53
   at a time, so be careful.
 
54
 
 
55
10. You should be redirected to the 'Edit' screen of the connection
 
56
    utility.
 
57
 
 
58
11. If you want to, you can go to the Test page and execute arbitrary
 
59
    SQL queries to see whether the connection is working as expected.
 
60
 
 
61
 
 
62
Using SQL Scripts
 
63
-----------------
 
64
 
 
65
You can create SQL Scripts in the content space.  For example:
 
66
 
 
67
12. Go to Zope root.
 
68
 
 
69
13. Add an SQL script (you can use the Common Tasks box on the left,
 
70
    or the Add action on the right).
 
71
 
 
72
14. Click on the name of your new SQL script.
 
73
 
 
74
15. Choose a connection name (the one you entered in step 29) from the
 
75
    drop-down.
 
76
 
 
77
16. Enter your query and click on the 'Save Changes' button.
 
78
 
 
79
17. You can test the script in the -- surprise! -- Test page.