Many thanks, I feel a litle stupid for not thinking of that myself :-)
And I'm glad that I joined this list, if I had asked that question in one of
the other lists, or in the news-groups I would have to jump in the water to
douse the flames ;-)
This list is simply the best thanks to people like you.
> -----Original Message-----
> From: Johnathan Thibodeau [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, May 31, 2001 4:46 PM
> To: Michael Risser
> Cc: '[EMAIL PROTECTED]'
> Subject: Re: DBI
>
>
> Once you've connected to your database with connect(), you can run any
> valid SQL query (and whatever non-standard MySQL querys) you want by
> calling prepare(SQL query) on the database object, and then
> execute() on
> the prepare'ed object. Confused? Maybe not, but I'm sure
> someone out there
> is.
>
> Time for an example:
>
> use DBI;
>
> # Define some variables like $user, $password, $database...
>
> $dbh = DBI->connect("DBI:mysql:$database", $user, $password)
> || die "bad";
> $sth = $dbh->prepare("SHOW TABLES");
> $sth->execute();
>
> # Then use fetchrow() (or fetchrow_hashref(), or
> fetchrow_arrayref()) to
> # get the next row of results.
>
> while ($result = $sth->fetchrow) {
> print $result . "\n";
> }
>
> If I haven't left anything out (I've cut and pasted just to
> make sure it
> runs), this will print out all of the tables found in
> whatever database
> you're looking in.
>
> Have fun.
>
> Johnathan Thibodeau
>
> Pound bang user bin perl
> fork while true
>
> On Thu, 31 May 2001, Michael Risser wrote:
>
> > I'm trying to write a Perl script which will connect to a
> MySQL database and
> > create certain tables if they do not already exist. Is
> there a way to send a
> > query such as "SHOW TABLES" and read the result into a
> variable for parsing?
> >
> > --------------------------------------------
> > Michael D. Risser
> > Machine Vision Products, Inc.
> > 760-438-1138 ext 107
> > --------------------------------------------
> > -- Due to the current economic situation, the light at the
> end of the tunnel
> > will be turned off until further notice.
> >
>
>
>