Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Zope: Dev

Programmatically accessing Z SQL Methods

 

 

Zope dev RSS feed   Index | Next | Previous | View Threaded


mike at compar

Mar 4, 1999, 9:09 AM

Post #1 of 4 (471 views)
Permalink
Programmatically accessing Z SQL Methods

I've got a pretty solid understanding of how to get around Zope from the
Product API point of view, and there is good documentation on using Z SQL
Methods from the DTML point of view. I'm finding myself in the grey
overlapping area, and there isn't a lot of documentation yet. I'm finding
myself having trouble getting started. Here's a deal: If I get a boost up the
learning curve with a few answers, I'll put it in a How-To once I understand
it all.

I would like the user to select the Database Connection when my Product is
being added. When the Product installs itself, I want it to check the
database it's been passed for the existance of a particular table. If it does
not exist, I want to create said table and do some initial populating.

So far my scheme for doing this involves adding a Z SQL Method to the
current folder, putting some SQL in it, running it, putting some SQL in it,
running it, etc, etc, and then removing it when I'm done. This seems like a
stupid way to go about things. I'd much rather just be able to take my
connection and submit some SQL programmatically. So, I guess question is
simply, "How do I submit an SQL query, starting from a connection_id?"

Thanks,
Mike.

--
--- | Mike Pelletier Work: 519-746-1607
/opeware! | Software Developer Home: 519-725-7710
--- | mike [at] zopeware Fax: 519-746-7566
http://www.zopeware.com | Zopeware is not endorsed by Digital Creations


neves at inf

Mar 4, 1999, 2:42 PM

Post #2 of 4 (458 views)
Permalink
Re: Programmatically accessing Z SQL Methods [In reply to]

Mike Pelletier wrote:
>
> I would like the user to select the Database Connection when my Product is
> being added.

Take a look at the function SQLConnectionIDs(self) in
lib/python//Products/ZSQLMethods/SQL.py

It selects all avaiable Database conections ids.

> When the Product installs itself, I want it to check the
> database it's been passed for the existance of a particular table. If it does
> not exist, I want to create said table and do some initial populating.

Some databases connectors have a standard api for querying tables and
columns. The tab browse calls it. The problem is that not all DB
connectors completely implements the api. The MySQL one, for example,
doesn't implements it. With it you have to directly query the DB.

If you have the connection id, you get the connection with:
connection = getattr(self, self.connection_id)

self is your product.

Connection is an object that implements a __call__ method. You should
make your query:
dummy, result = self.connection().query(command)

Oops! The query method returns a tuple, I don't remember what is the
first returned value. I didn't used it. See the source.

> So far my scheme for doing this involves adding a Z SQL Method to the
> current folder, putting some SQL in it, running it, putting some SQL in it,
> running it, etc, etc, and then removing it when I'm done. This seems like a
> stupid way to go about things. I'd much rather just be able to take my
> connection and submit some SQL programmatically. So, I guess question is
> simply, "How do I submit an SQL query, starting from a connection_id?"

I've did somenthing like it in the PMySQLInput wizard, see it in the
contrib area.

hope this helps,
--
Paulo Eduardo Neves
PUC-Rio de Janeiro
Pager: Central: 292-4499 cod. 213 99 64
ou use a URL: http://www.learn.fplf.org.br/neves/mensagempager.html


Paul at digicool

Mar 5, 1999, 6:21 AM

Post #3 of 4 (457 views)
Permalink
RE: Programmatically accessing Z SQL Methods [In reply to]

Mike wrote:
> myself having trouble getting started. Here's a deal: If I
> get a boost up the
> learning curve with a few answers, I'll put it in a How-To
> once I understand
> it all.

Instead of answering the question (which with my IQ would be something
like, "use a crescent wrench"), I'll instead suggest a counter-deal with
the ZDP crowd.

As you guys start moving over the ground of filling in the gaping holes
in the Zope docs, you'll come up with things you can answer and things
you can't. The lack of a Product API reference doc is a perfect
example.

I propose that you guys go ahead an collect the questions and then once
a week I'll get some time from the folks here to answer the questions.

Thoughts?

--Paul


mj at antraciet

Mar 5, 1999, 7:47 AM

Post #4 of 4 (455 views)
Permalink
Re: [ZDP] RE: [Zope-dev] Programmatically accessing Z SQL Methods Methods [In reply to]

At 14:21 05/03/99 , Paul Everitt wrote:
>As you guys start moving over the ground of filling in the gaping holes
>in the Zope docs, you'll come up with things you can answer and things
>you can't. The lack of a Product API reference doc is a perfect
>example.

My answer to questions without obvious answers is to get out the tools and
look under the hood.

>
>I propose that you guys go ahead an collect the questions and then once
>a week I'll get some time from the folks here to answer the questions.
>
>Thoughts?
>

Sounds very fine to me. We'll have to set up facilities so it is possible
to query the current FAQ database (we have to set up a database... Pavlos
effort is a good start) for unaswered questions.

When looking under the hood I might misinterpret things a bit (see my
progress on the Principia Draft...). I would like it if you guys went over
the new entries for that week and correct any glaring mistakes we might
make. Again, the facilities should be there to ask the FAQ DB for entries
added/modified recently.

--
M.J. Pieters, Web Developer
| Antraciet http://www.antraciet.nl
| Tel: +31-35-6254545 Fax: +31-35-6254555
| mailto:mj [at] antraciet http://www.antraciet.nl/~mj
| PGP: http://wwwkeys.nl.pgp.net:11371/pks/lookup?op=get&search=0xA8A32149
------------------------------------------

Zope dev RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.