[Zope] database connection in script

2007-03-07 Thread javi lopez

how to create a database connection in a script python
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] database connection in script

2007-03-07 Thread Jonathan


- Original Message - 
From: javi lopez [EMAIL PROTECTED]

To: zope@zope.org
Sent: Wednesday, March 07, 2007 7:48 AM
Subject: [Zope] database connection in script



how to create a database connection in a script python


What kind of database are you trying to connect to?


Jonathan
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] database connection in script

2007-03-07 Thread javi lopez

my database is Mysql. can you help me?Thanks
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] database connection in script

2007-03-07 Thread Jonathan


- Original Message - 
From: javi lopez [EMAIL PROTECTED]

To: Jonathan [EMAIL PROTECTED]; zope@zope.org
Sent: Wednesday, March 07, 2007 7:54 AM
Subject: Re: [Zope] database connection in script



my database is Mysql. can you help me?Thanks



The easiest way to do this is to:

1- create a database/table in MySQL
2- use the ZMI to add a Z SQL Method
3- you can then have your python script call the Z SQL Method to access (ie 
add/modify/delete/search) the MySQL db


Here is a link to the relational database connectivity section of the Zope 
Book:


http://www.plope.com/Books/2_7Edition/RelationalDatabases.stx



Jonathan


___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] database connection in script

2007-03-07 Thread Maciej Wisniowski
 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
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )