Re: [egenix-support] DSN

"Charlie Clark" <[email protected]>
Newsgroups gmane.comp.web.zope.database
Organization eGenix.com
Message-ID <[email protected]>
Am 29.01.2007, 12:05 Uhr, schrieb Sven Plage <[email protected]>:

> Sehr geehrte Damen und Herren,
> ich habe in Zope eine "mxODBC Database Connection" angelegt und dort  
> auch einen entsprechenden "Database Connection String  
> (DSN=testDB;DATABASE=testDB;UID=root;PWD=) " angelegt. Nun möchte ich  
> aus meinem py Script darauf zugreifen, ohne User und Password übergeben  
> zu müssen. Wie ist das möglich?
>  conn = mx.ODBC.iODBC.DriverConnect('DSN=testDB')

Sehr geehrter Herr Plage, Dear Mr. Plage,

ich leite die Antwort auf diese Frage auch an die Zope-DB Mailing-Liste  
weiter, da es hierbei um Zope handelt. Wenn Sie ein Connection Object  
angelegt haben, erledigt dieser die Verbindung an die Datenbank für Sie.  
Abfragen werden normalerweise mit ZSQL-Methoden gemacht, die immer mit  
einem bestimmten Connection verbunden sind. Legen so eine Methode names  
"myquery" an. Sie können diese dann von einem PythonScript aus aufrufen:

results = context.myquery()

Mehr über ZSQL-Methoden können Sie im Zope-Buch nachlesen. Das Buch gibt  
es auch Deutsch.

answer forwarded to Zope-DB mailing list.

Once you have created a Connection Object in Zope this is responsible for  
managing the communication between Zope and the database. Queries are  
usually managed by ZSQL Methods which use specific connections. If you  
create a ZSQL Method called "myquery" you can call it from a PythonScript  
like this:

results = context.myquery()

More informaton about ZSQL can be found in the Zope Book.

Charlie
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.