[Zope] database connection in script

Maciej Wisniowski maciej.wisniowski at coig.katowice.pl
Wed Mar 7 08:09:21 EST 2007


> how to create a database connection in a script python????
This is your third (or more) thread about this during few hours!
Ask a specific questions and be patient please.

In general seems that you have no idea how it all works.

So my advice is:
1. Read abour basics of relational database connectivity in zope
2. Go to your portal folder via ZMI and create database
connection to your RDBMS
3. Still in ZMI create ZSQLMethods you need
4. In your product just call these ZSQLMethods via their id's like
result = self.mymethod1()


If this works then you may:
1. Change addform of your product to be able
to select specific database connection from the list
of available connections. Your product won't have
hardcoded connection id.
2. Create ZSQLMethods in your product as typical objects.

Instead of using ZSQLMethods you may use:

context.db_conn_id.db.query('YOUR QUERY HERE')

as Robert Rottermann suggested.

-- 
Maciej Wisniowski


More information about the Zope mailing list