Re: perl DBI does not do execute mysql statement

2007-06-11 Thread Kemin Zhou

Baron Schwartz wrote:

Kemin Zhou wrote:

Hi All,
I have one of the toughest problem to solve now.  I have not been 
able to sleep well in the last three days.


There is a simple query

insert into table foo (column1, column2, column5)
select $col
from bar

If I run this query by hand whatever the value of $col, it works 
fine.   The insertion was done.


If I run this query with other values of $col this sql works fine if 
$col is not name.


If $col eq "name" then the insertion does not happen and no error 
message is given.

(Of course, if I run the same query by hand, then this works fine).


I would first get some sleep, then enable DBI tracing and turn on the 
MySQL general query log and see what query is really getting sent to 
the server.


Baron


Hi Baron,
Best advice.  I forgot about this one.  I fixed the bug but I don't know 
how.  I randomly changed
form feature of the connection of the DBI object.  Before this I 
experimented the ` quote symbol
it did not help.  To figure out what had caused the problem I need to 
ask the sysadmin for this.


I was working on a database that I don't have easy access of the log 
files. 


Thanks for the help.

Kemin




--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: perl DBI does not do execute mysql statement

2007-06-09 Thread Baron Schwartz

Kemin Zhou wrote:

Hi All,
I have one of the toughest problem to solve now.  I have not been able 
to sleep well in the last three days.


There is a simple query

insert into table foo (column1, column2, column5)
select $col
from bar

If I run this query by hand whatever the value of $col, it works fine.   
The insertion was done.


If I run this query with other values of $col this sql works fine if 
$col is not name.


If $col eq "name" then the insertion does not happen and no error 
message is given.

(Of course, if I run the same query by hand, then this works fine).


I would first get some sleep, then enable DBI tracing and turn on the 
MySQL general query log and see what query is really getting sent to the 
server.


Baron

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: perl DBI does not do execute mysql statement

2007-06-09 Thread Paul DuBois

At 6:54 PM -0700 6/9/07, Kemin Zhou wrote:

Hi All,
I have one of the toughest problem to solve now.  I have not been 
able to sleep well in the last three days.


There is a simple query

insert into table foo (column1, column2, column5)
select $col
from bar

If I run this query by hand whatever the value of $col, it works fine.  
The insertion was done.


If I run this query with other values of $col this sql works fine if 
$col is not name.


If $col eq "name" then the insertion does not happen and no error 
message is given.

(Of course, if I run the same query by hand, then this works fine).

Not sure how crazy this could be.  Any clue?


No, because you're describing the problem in English without showing
any of the code that doesn't work.  How can anyone help you?

--
Paul DuBois, MySQL Documentation Team
Madison, Wisconsin, USA
MySQL AB, www.mysql.com

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: perl/dbi - insert into server2.db2.table2 select * from server1.db1.table1

2006-09-29 Thread dpgirago

| Hi All,
|
| I have 2 separate mysql servers and need to import data from a table on
| sever1 to
| a table on server2.  This would need to be done in Perl.
|
| The script in question already has open handles to both servers, so I
| know I can
| select all the rows from server1 and process them one by one and insert
| into the table on server2, but I was wondering if there was a more
| simple way to do this which would allow me to transfer the data from one
| database handle directly to another?
|
| Looking on google, the closest example I can find is something like :
|
| #!/usr/bin/perl
| use DBI;
|
| $dbh1=.;
| $dbh2=.;
| ...
|
| $statement = "select a,b,c,d,... from table1 where condition='$value'";
| $sth=$dbh1->prepare($sql);
| my @results;
| while (@results = $sth->fetchrow_array) {
|
|  # build placeholders based on num of fields
|  my $placeholders;
|  $placeholders .= ($placeholders ? ",?" : "?") for (@results);
|
|  my $sth2 = $dbh2->prepare("INSERT INTO table2 values
| ($placeholders);");
|  $sth2->execute(@results);
|  $sth2->finish;
| }
|
| $sth1->finish;
| $dbh1->disconnect();
| $dbh2->disconnect();
|
| George Law
| [EMAIL PROTECTED]
| MSN: [EMAIL PROTECTED]
| Phone: 864-678-3161

George,

Did you try to "INSERT INTO db2.tablename SELECT fields from db1.tablename
where field='Somevalue'" across different servers? Don't know if it's
possible but it would certainly be more efficient.

David



-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: perl/dbi - insert into server2.db2.table2 select * from server1.db1.table1

2006-09-29 Thread Dan Buettner

George, that's probably about the easiest way you could do it in perl.
If you want every column transferred you could do a "SELECT *" instead
of enumerating columns I think.

Dan


On 9/29/06, George Law <[EMAIL PROTECTED]> wrote:

Hi All,

I have 2 separate mysql servers and need to import data from a table on
sever1 to
a table on server2.  This would need to be done in Perl.

The script in question already has open handles to both servers, so I
know I can
select all the rows from server1 and process them one by one and insert
into the table on server2, but I was wondering if there was a more
simple way to do this which would allow me to transfer the data from one
database handle directly to another?

Looking on google, the closest example I can find is something like :

#!/usr/bin/perl
use DBI;

$dbh1=.;
$dbh2=.;
...

$statement = "select a,b,c,d,... from table1 where condition='$value'";
$sth=$dbh1->prepare($sql);
my @results;
while (@results = $sth->fetchrow_array) {

  # build placeholders based on num of fields
  my $placeholders;
  $placeholders .= ($placeholders ? ",?" : "?") for (@results);

  my $sth2 = $dbh2->prepare("INSERT INTO table2 values
($placeholders);");
  $sth2->execute(@results);
  $sth2->finish;
}

$sth1->finish;
$dbh1->disconnect();
$dbh2->disconnect();




George Law
[EMAIL PROTECTED]
MSN: [EMAIL PROTECTED]
Phone: 864-678-3161


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]




--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



RE: Perl DBI does not print error.

2005-03-10 Thread John Trammell
The print string you show is:

"prepare: $insert_sql: $DBI::errstr"

but your error message is

Unable to execute query: DBI::db=HASH(0x8647df0)->errstr

I think your problem is with a print line like:

print "Unable to execute query: $dbh->errstr"

and Perl is interpolating $dbh, but not the full method call
$dbh->errstr.
You want instead:

print "Unable to execute query: ", $dbh->errstr

or

print "Unable to execute query: @{[ $dbh->errstr ]}"

You will probably have better luck with your Perl questions on Usenet
newsgroup comp.lang.perl.misc, or on the Perl Monks site
www.perlmonks.org.

> -Original Message-
> From: sam [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, March 10, 2005 7:56 AM
> To: Mysql
> Subject: Perl DBI does not print error.
> 
> Hi,
> 
> The perl DBI does not prints error message:
> $sth = $dbh->prepare($insert_sql)
>|| print ERRFILE_OUT "prepare: $insert_sql: $DBI::errstr";
> 
> The out of this error only does not print why the error was occurred.
> eg.
> Unable to execute query: DBI::db=HASH(0x8647df0)->errstr:
> 
> Dan anyone please tell me how to prints how a description of 
> the error 
> from DBI when sql executed failed?
> 
> Thanks
> Sam
> 
> 
> -- 
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:
> http://lists.mysql.com/[EMAIL PROTECTED]
> 
> 

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: Perl DBI does not print error.

2005-03-10 Thread Joerg Bruehe
Hi!


Am Do, den 10.03.2005 schrieb sam um 14:55:
> Hi,
> 
> The perl DBI does not prints error message:
> $sth = $dbh->prepare($insert_sql)
>|| print ERRFILE_OUT "prepare: $insert_sql: $DBI::errstr";
> 
> The out of this error only does not print why the error was occurred.
> eg.
> Unable to execute query: DBI::db=HASH(0x8647df0)->errstr:

"Works as designed" (but not as intended ... )

> 
> Dan anyone please tell me how to prints how a description of the error 
> from DBI when sql executed failed?

By using "or" where you used "||".
Both do an "or" operation, but have different priorities relative to the
"=" assignment.

See the example in "Programming Perl" (Wall, Christiansen, Schwartz) on
page 89 (and other Perl references).

HTH,
Joerg

-- 
Joerg Bruehe, Senior Production Engineer
MySQL AB, www.mysql.com


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: perl DBI vs. prepare and execute do

2003-12-06 Thread Joakim Ryden
On 12/6/03 8:52 AM Dan Anderson wrote:

I am using the Perl DBI to connect to a mySQL database.  I am
using prepare and execute statements to send the query to the database
and then execute it.  Is there any benefit to doing this versus using
do?
The O'Reilly book "Programming the Perl DBI" says:

...the do() method supplied by the DBI makes executing non-SELECT 
statements much simpler than repeatedly preparing and executing statements.

...

There is a drawback to doing this, however: performance. If you invoked 
do() repeatedly to insert a huge number of rows into a table, you could 
be preparing a statement handle many times more than is required, 
especially if the statement contained placeholder variables.

HTH.

--Jo


smime.p7s
Description: S/MIME Cryptographic Signature


Re: PERL DBI DBD mysql / REMOTE ACCESS

2003-10-30 Thread Egor Egorov
"nm" <[EMAIL PROTECTED]> wrote:
> 
> I can login on console. I can telnet 192.168.1.20 3306 from a remote host
> but when I try to connect using perl DBI i get this error:
> 
> DBI connect('database=test;hostname=192.168.1.20','root',...) failed: Access
> denied for user: '[EMAIL PROTECTED]' (Using password: YES)
> 
> I added Host 192.168.1.10 user root with passowrd in mysql user table.
> 
> Ideas? What else?

If you edit privilege tables explicitly you should execute FLUSH PRIVILEGES.



-- 
For technical support contracts, goto https://order.mysql.com/?ref=ensita
This email is sponsored by Ensita.net http://www.ensita.net/
   __  ___ ___   __
  /  |/  /_ __/ __/ __ \/ /Egor Egorov
 / /|_/ / // /\ \/ /_/ / /__   [EMAIL PROTECTED]
/_/  /_/\_, /___/\___\_\___/   MySQL AB / Ensita.net
   <___/   www.mysql.com




-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: PERL DBI DBD mysql / REMOTE ACCESS

2003-10-30 Thread Johannes Ullrich

> I added Host 192.168.1.10 user root with passowrd in mysql user table.

Did you flush privileges?
did you hash the password using the 'password' function?
did you type the password correctly ?



> 
> Ideas? What else?
> 
> Thanks.
-- 
--
Johannes Ullrich [EMAIL PROTECTED]
pgp key: http://johannes.homepc.org/PGPKEYS
--
   "We regret to inform you that we do not enable any of the 
security functions within the routers that we install."
 [EMAIL PROTECTED]
--



-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: Perl DBI secret command?

2003-01-18 Thread Markus Reger
hi
pls
look into "man DBI" and find there this command. 
kr
mr



>>> Jeff Snoxell <[EMAIL PROTECTED]> 01/18/03 10:45 AM >>>
Hi,

just stumbled across the following piece of code:

my $rowcount = $sth->rows();

And I checked it out compared to a count of the fetched rows from an SQL 
QUERY. AND It matched exactly!

BUT, I can't find the command "rows()" in the DBI documentation.

What's the story? Have I unearthed a conspiracy?


Jeff


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: Perl DBI secret command?

2003-01-18 Thread Paul DuBois
At 9:39 + 1/18/03, Jeff Snoxell wrote:

Hi,

just stumbled across the following piece of code:

my $rowcount = $sth->rows();

And I checked it out compared to a count of the fetched rows from an 
SQL QUERY. AND It matched exactly!

BUT, I can't find the command "rows()" in the DBI documentation.

What's the story? Have I unearthed a conspiracy?

You probably looked for it with parentheses.  When you do find it, you'll
note that it discourages use of the rows method for SELECT statements,
and recommends that you count the rows yourself as you fetch them.



Jeff



sql, query

-
Before posting, please check:
  http://www.mysql.com/manual.php   (the manual)
  http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: Perl DBI secret command?

2003-01-18 Thread Joseph Bueno
No conspiracy, read it again ! ;)
http://www.perldoc.com/cpan/DBI.html#rows

Joseph Bueno

Jeff Snoxell wrote:
> Hi,
> 
> just stumbled across the following piece of code:
> 
> my $rowcount = $sth->rows();
> 
> And I checked it out compared to a count of the fetched rows from an SQL
> QUERY. AND It matched exactly!
> 
> BUT, I can't find the command "rows()" in the DBI documentation.
> 
> What's the story? Have I unearthed a conspiracy?
> 
> 
> Jeff
> 
> 
> -
> Before posting, please check:
>   http://www.mysql.com/manual.php   (the manual)
>   http://lists.mysql.com/   (the list archive)
> 
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail
> <[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
> 



-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




RE: Perl DBI $sth->fetchrow_hashref() persistence?

2003-01-15 Thread Joe Stump
I'm not sure how Perl works on variable assignment. If $sth is passing a
reference to $record finish() may kill the variable $record holds a
reference to during garbage collection. If it *assigns* the row to $record
(meaning $record holds a copy of the record data and not a reference to
where the data is actually stored) then you should be able to use it all you
want.

Maybe one of the many perl monks will know more.

--Joe


--
Joe Stump <[EMAIL PROTECTED]>
http://www.joestump.net


-Original Message-
From: Jeff Snoxell [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 15, 2003 6:22 AM
To: [EMAIL PROTECTED]
Subject: Perl DBI $sth->fetchrow_hashref() persistence?


Hi,

if I call:

my $record = $sth->fetchrow_hashref();

then:

$sth->finish();

How valid is it for me to keep referring to my $record hash pointer?

Thanks,


Jeff Snoxell
Aetherweb Ltd
http://www.aetherweb.co.uk
[SPAM FILTER FODDER: MySQL, QUERY]


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail
<[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




RE: Perl DBI or C++ API Help!

2002-12-04 Thread Norris, Joseph
Q&D  answer in PERL!


my ($file);

$file = 'database_names';

$cmd = qq!show databases;!;

open O, ">cmd" or die "could open cmd - $!";
print O "$cmd\n";
close O;

system ("mysql -uusername -ppassword < cmd > $file") 
== 0 or die "could not do system - $!";

open I, "<$file" or die "could not open $file - $!";
while (){
print "$_";
}
close I;



-Original Message-
From: Bernd Prager [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, December 03, 2002 2:33 PM
To: Sarah Killcoyne; [EMAIL PROTECTED]
Subject: Re: Perl DBI or C++ API Help!


- Original Message -
From: "Sarah Killcoyne" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, December 03, 2002 11:14 AM


> I need to be able to connect to mysql through a perl or C++ script without
> knowing the name of the database to connect to.

,,,

I'm not an expert om the C++ API. But if the host is a UNIX system
you can do a RSH command in C++ as well as in Perl.
"mysql -u username 'show databases;'"

Maybe there's a better solution, but in worst case this would do it.


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: Perl DBI or C++ API Help!

2002-12-04 Thread Stephen Patterson
Sarah Killcoyne wrote:


I need to be able to connect to mysql through a perl or C++ script without
knowing the name of the database to connect to.  I can't seem to find a way
to do this.  Is it possible to either: look up database names so I can pick
one before connecting or connect without a database name so I can "show
databases;" and pick one then?  The reason for this is, this script will be
creating the database we need new each time with a different name depending
on how the user wants it so it's possible that there are no databases set up
at all or a differnt named one each time.  My book only shows me how to do
it if I know the name.
 

One way could be to connect to the test database and then run the SQL 
"show databases".



-
Before posting, please check:
  http://www.mysql.com/manual.php   (the manual)
  http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



Re: Perl DBI or C++ API Help!

2002-12-03 Thread Bernd Prager
- Original Message -
From: "Sarah Killcoyne" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, December 03, 2002 11:14 AM


> I need to be able to connect to mysql through a perl or C++ script without
> knowing the name of the database to connect to.

,,,

I'm not an expert om the C++ API. But if the host is a UNIX system
you can do a RSH command in C++ as well as in Perl.
"mysql -u username 'show databases;'"

Maybe there's a better solution, but in worst case this would do it.


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




RE: Perl DBI or C++ API Help!

2002-12-03 Thread Salada, Duncan
For Perl...

Take a look at the data_sources DBI class method
http://search.cpan.org/author/TIMB/DBI-1.32/DBI.pm#DBI_Class_Methods
or the ListDBs MetaData Method for DBD::mysql
http://search.cpan.org/author/JWIED/DBD-mysql-2.1020/lib/DBD/mysql.pod#Priva
te_MetaData_Methods

Duncan

---
Duncan Salada
Titan Systems Corporation
301-925-3222 x375


-Original Message-
From: Sarah Killcoyne [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, December 03, 2002 11:14 AM
To: [EMAIL PROTECTED]
Subject: Perl DBI or C++ API Help!


I need to be able to connect to mysql through a perl or C++ script without
knowing the name of the database to connect to.  I can't seem to find a way
to do this.  Is it possible to either: look up database names so I can pick
one before connecting or connect without a database name so I can "show
databases;" and pick one then?  The reason for this is, this script will be
creating the database we need new each time with a different name depending
on how the user wants it so it's possible that there are no databases set up
at all or a differnt named one each time.  My book only shows me how to do
it if I know the name.

Thanks!!
Sarah

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




RE: perl dbi and mysql question

2002-11-08 Thread Shon Stephens
yeah, but i was looking for a function. mostly just to see if a matching
function to dbh->tables() existed.

-Original Message-
From: Grigor, Peter [mailto:pgrigor@;aseedge.com]
Sent: Friday, November 08, 2002 10:07 AM
To: 'Shon Stephens'; '[EMAIL PROTECTED]'
Subject: RE: perl dbi and mysql question


Of course, you could have also used:

$stmt = $db->prepare("show databases");

Peter
<^_^>

-Original Message-
From: Shon Stephens [mailto:sstephens@;corp.goamerica.net]
Sent: Friday, November 08, 2002 9:50 AM
To: Shon Stephens; '[EMAIL PROTECTED]'
Subject: RE: perl dbi and mysql question


eureka! i found it!

@dbs = $dbh->func('_ListDBs');

-Original Message-
From: Shon Stephens [mailto:sstephens@;corp.goamerica.net]
Sent: Friday, November 08, 2002 9:45 AM
To: '[EMAIL PROTECTED]'
Subject: perl dbi and mysql question


i am using perl dbi with dbd::mysql. i know that using the dbi function,
$dbh->tables (), will list all the tables in a database. is there a function
that will show all the databases on a server?

thanks,
shon

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail
<[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail
<[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




RE: perl dbi and mysql question

2002-11-08 Thread Grigor, Peter
Of course, you could have also used:

$stmt = $db->prepare("show databases");

Peter
<^_^>

-Original Message-
From: Shon Stephens [mailto:sstephens@;corp.goamerica.net]
Sent: Friday, November 08, 2002 9:50 AM
To: Shon Stephens; '[EMAIL PROTECTED]'
Subject: RE: perl dbi and mysql question


eureka! i found it!

@dbs = $dbh->func('_ListDBs');

-Original Message-
From: Shon Stephens [mailto:sstephens@;corp.goamerica.net]
Sent: Friday, November 08, 2002 9:45 AM
To: '[EMAIL PROTECTED]'
Subject: perl dbi and mysql question


i am using perl dbi with dbd::mysql. i know that using the dbi function,
$dbh->tables (), will list all the tables in a database. is there a function
that will show all the databases on a server?

thanks,
shon

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail
<[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail
<[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: perl dbi and mysql question

2002-11-08 Thread stibs-pi
No clue of dbi/dbd but the query SHOW DATABASES does what it tells.

STIBS

- Original Message -
From: "Shon Stephens" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, November 08, 2002 3:44 PM
Subject: perl dbi and mysql question


> i am using perl dbi with dbd::mysql. i know that using the dbi function,
> $dbh->tables (), will list all the tables in a database. is there a
function
> that will show all the databases on a server?
>
> thanks,
> shon
>
> -
> Before posting, please check:
>http://www.mysql.com/manual.php   (the manual)
>http://lists.mysql.com/   (the list archive)
>
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail <[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
>


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




RE: perl dbi and mysql question

2002-11-08 Thread Shon Stephens
eureka! i found it!

@dbs = $dbh->func('_ListDBs');

-Original Message-
From: Shon Stephens [mailto:sstephens@;corp.goamerica.net]
Sent: Friday, November 08, 2002 9:45 AM
To: '[EMAIL PROTECTED]'
Subject: perl dbi and mysql question


i am using perl dbi with dbd::mysql. i know that using the dbi function,
$dbh->tables (), will list all the tables in a database. is there a function
that will show all the databases on a server?

thanks,
shon

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail
<[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: Perl DBI Interfacer

2002-09-21 Thread Brian Reichert

On Sat, Sep 21, 2002 at 02:06:01AM -0500, Kevin wrote:
> Hello, I was wondering if anyone knows PERL & DBI, if so please respond to 
>[EMAIL PROTECTED] personally, or to the list
> 
> 
> My question is, I'm trying to build a 'custom' querier for a survey program... based 
>on the information submitted, the program will generate an SQL Query statement. The 
>command that my program works absolutely find if I copy/paste it into MySQL, however, 
>DBI won't pass it... if I pass the QUERY Along to DBI typed in manually it works...

I'm not in the mood to unpeel this code, just to see output.

As I'm curious, could you set the DBI trace (to 2 or better), run
your query, and show us the logs?  That we can see what DBI is
getting, and what it's actually complaining about (since you didn't
tell us...)

> Thanks
> Kevin

-- 
Brian 'you Bastard' Reichert<[EMAIL PROTECTED]>
37 Crystal Ave. #303Daytime number: (603) 434-6842
Derry NH 03038-1713 USA Intel architecture: the left-hand path

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: Perl/DBI & load data local

2002-06-21 Thread Paul DuBois

At 10:23 -0800 6/21/02, nellA hciR wrote:
>iH
>
>running mySQL 3.23.51, i have a my.cnf file with local-infile=1 and 
>am able to use the "load data local file" command when running run 
>the interactive mysql app (command line).
>
>my problem is that i can not use the "load data local" command from 
>a Perl script. i am connecting as the same user and i do with the 
>command line. other command such as connect, disconnect, insert, 
>select do work
>
>what am i missing to allow the same access via Perl as with the command line

Add:

;mysql_read_default_group=client

to the end of your DSN string.

>
>thanks
>- hcir
>[EMAIL PROTECTED]


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: Perl DBI

2002-05-23 Thread Curtis Maurand


  Yes.

Denny said:
> Hi,
>
> How can i use Perl DBI to create tables in mysql?
>
> Denny
>
> __
> Do You Yahoo!?
> Everything you'll ever need on one web page
> from News and Sport to Email and Music Charts
> http://uk.my.yahoo.com
>
> -
> Before posting, please check:
>   http://www.mysql.com/manual.php   (the manual)
>   http://lists.mysql.com/   (the list archive)
>
> To request this thread, e-mail <[EMAIL PROTECTED]> To
> unsubscribe, e-mail
> <[EMAIL PROTECTED]> Trouble
> unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: Perl DBI

2002-05-23 Thread Viliam Batka

Hi Denny,

>How can i use Perl DBI to create tables in mysql?

I am not an expert in CPAN modules for Perl but I am using the DBD module
that needs DBI module for access the MySQL. Please see the man pages for DBI
module.

I am using the:
   DBI-1.22
   DBD-mysql-2.1017

You can installing all mentioned and all dependant modules with

  perl -MCPAN -e 'install Bundle::DBD::mysql'

Before rushing execute the perl command mentioned above you need to have
compiled MySQL client library and source files (especially header files)
otherwise you are not able to install the DBD:mysql module on your platform.
Please read INSTALL.htm file that is delivered with the DBD::mysql module.

After successful instalation of the DBD::mysql module I have used example
from DBD::mysql module documentation.

Please see the mentioned EXAMPLE below:
 #!/usr/bin/perl

 use strict;
 use DBI();

 # Connect to the database.
 my $dbh = DBI->connect("DBI:mysql:database=test;host=localhost",
"joe", "joe's password",
{'RaiseError' => 1});

 # Drop table 'foo'. This may fail, if 'foo' doesn't exist.
 # Thus we put an eval around it.
 eval { $dbh->do("DROP TABLE foo") };
 print "Dropping foo failed: $@\n" if $@;

 # Create a new table 'foo'. This must not fail, thus we don't
 # catch errors.
 $dbh->do("CREATE TABLE foo (id INTEGER, name VARCHAR(20))");

 # INSERT some data into 'foo'. We are using $dbh->quote() for
 # quoting the name.
 $dbh->do("INSERT INTO foo VALUES (1, " . $dbh->quote("Tim") . ")");

 # Same thing, but using placeholders
 $dbh->do("INSERT INTO foo VALUES (?, ?)", undef, 2, "Jochen");

 # Now retrieve data from the table.
 my $sth = $dbh->prepare("SELECT * FROM foo");
 $sth->execute();
 while (my $ref = $sth->fetchrow_hashref()) {
   print "Found a row: id = $ref->{'id'}, name = $ref->{'name'}\n";
 }
 $sth->finish();

 # Disconnect from the database.
 $dbh->disconnect();


I hope that it helps.

Viliam Batka

- Original Message -
From: "Denny" <[EMAIL PROTECTED]>
To: "Mysql maillist" <[EMAIL PROTECTED]>
Sent: Thursday, May 23, 2002 8:02 PM
Subject: Perl DBI


> Hi,
>
> How can i use Perl DBI to create tables in mysql?
>
> Denny
>
> __
> Do You Yahoo!?
> Everything you'll ever need on one web page
> from News and Sport to Email and Music Charts
> http://uk.my.yahoo.com
>
> -
> Before posting, please check:
>http://www.mysql.com/manual.php   (the manual)
>http://lists.mysql.com/   (the list archive)
>
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail
<[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
>


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




RE: Perl DBI & DBD & Show Table Modules Best Dir Install Choices!

2001-09-15 Thread Dipl.-Inf. Guus Leeuw jr.

Bob,

As soon as you compiled and installed perl itself, the Config
module of perl will tell any Makefile.PL driven package where to
install itself: under the directory structure of perl.

I don't know for sure, but I suppose DBI DBD installs via
Makefile.pl script... If not, do a perl -V to see where @INC
is pointing to. somewhere in that structure your DBI should be
installed, so that all programs in Perl can find it without
messing with @INC.

Cheers,
Guus

PS: database,sql,query,table for the antispam rules...

>  -Original Message-
>  From: bobby [mailto:bobby]On Behalf Of rjtalbo
>  Sent: Saturday, September 15, 2001 9:08 PM

[snipped]

>  Where is the most common and preferred Location for the Install??

[omitted]

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: Perl DBI: Same column name in different tables problem

2001-09-07 Thread Dana Powers

Or the perl way:

my %row;
@row{'f_handle','a_handle'} = $sth->fetchrow_array();

$row{f_handle} or $row{a_handle}are now set properly.

( if you really want a reference, you can say 'my $row = {};
@{$row}{'f_handle. )

dpk

- Original Message -
From: "Jeremy Zawodny" <[EMAIL PROTECTED]>
To: "Philip Mak" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Friday, September 07, 2001 10:48 PM
Subject: Re: Perl DBI: Same column name in different tables problem


> On Fri, Sep 07, 2001 at 10:03:03PM -0700, Philip Mak wrote:
> > Let's say I performed the following query using Perl DBI:
> >
> > $row = $dbh->selectrow_hashref(<<"~");
> > SELECT fanfics.handle, authors.handle
> > FROM fanfics, authors
> > WHERE fanfics.aid = authors.aid
> > ~
> >
> > I won't be able to access both fanfics.handle and authors.handle
> > this way, because they're called "handle". I would like to be able
> > to access them e.g. by doing $row->{fanfics.handle} and
> > $row->{authors.handle}, or something like that.
> >
> > What workarounds have people found for this problem?
>
> Use a column alias:
>
>   SELECT fanfics.handle as f_handle, authors.handle as a_handle
> FROM fanfics, authors
>WHERE fanfics.aid = authors.aid
>
> Then refer to them as $row->{a_handle} or $row->{f_handle}.
>
> Jeremy
> --
> Jeremy D. Zawodny, <[EMAIL PROTECTED]>
> Technical Yahoo - Yahoo Finance
> Desk: (408) 349-7878   Fax: (408) 349-5454   Cell: (408) 685-5936
>
> MySQL 3.23.41-max: up 2 days, processed 42,300,526 queries (237/sec. avg)
>
> -
> Before posting, please check:
>http://www.mysql.com/manual.php   (the manual)
>http://lists.mysql.com/   (the list archive)
>
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail
<[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
>
>
>


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: Perl DBI: Same column name in different tables problem

2001-09-07 Thread Jeremy Zawodny

On Fri, Sep 07, 2001 at 10:03:03PM -0700, Philip Mak wrote:
> Let's say I performed the following query using Perl DBI:
> 
> $row = $dbh->selectrow_hashref(<<"~");
> SELECT fanfics.handle, authors.handle
> FROM fanfics, authors
> WHERE fanfics.aid = authors.aid
> ~
> 
> I won't be able to access both fanfics.handle and authors.handle
> this way, because they're called "handle". I would like to be able
> to access them e.g. by doing $row->{fanfics.handle} and
> $row->{authors.handle}, or something like that.
> 
> What workarounds have people found for this problem?

Use a column alias:

  SELECT fanfics.handle as f_handle, authors.handle as a_handle
FROM fanfics, authors
   WHERE fanfics.aid = authors.aid

Then refer to them as $row->{a_handle} or $row->{f_handle}.

Jeremy
-- 
Jeremy D. Zawodny, <[EMAIL PROTECTED]>
Technical Yahoo - Yahoo Finance
Desk: (408) 349-7878   Fax: (408) 349-5454   Cell: (408) 685-5936

MySQL 3.23.41-max: up 2 days, processed 42,300,526 queries (237/sec. avg)

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: Perl DBI -- How to select all returned values into an array

2001-08-26 Thread Tim Bunce

On Sat, Aug 25, 2001 at 09:24:25PM -0500, Paul DuBois wrote:
> At 10:07 AM -0700 8/24/01, Katherine Porter wrote:
> >For single values I usually use this DBI function and query:
> >
> >   my $val =3D $dbh->selectrow_array("SELECT value FROM tab1 WHERE test=3D=
> >2");
> >
> >However, what if I want to store a bunch of values into an array?
> >
> >   my @vals =3D $dbh->?("SELECT value FROM tab1 WHERE test > 10");
> >
> >What's the syntax I'm missing above?  Any help appreciated!
> 
> my $ref = $dbh->selectcol_arrayref (single-column query);
> my @val = (defined ($ref) ? @{$ref} : () );

Or just:

  my @val = @{ $dbh->selectcol_arrayref(single-column query) || []};

And if you have RaiseError set then you don't need the '|| []' part.

Also, from DBI 1.20 onwards you can now say

  $dbh->selectcol_arrayref("select f1, f2 from ...", { Columns=>[1,2] });

and have all the fields flattened into a list. Very handy when building a hash.
But then for building a hash DBI 1.20 also has selectall_hashref()  :-)

"The Perl DBI - One call does it all" - almost :-)

Tim.

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: Perl DBI -- How to select all returned values into an array

2001-08-25 Thread s. keeling

On Fri, Aug 24, 2001 at 10:07:59AM -0700, Katherine Porter wrote:
> For single values I usually use this DBI function and query:
> 
>   my $val =3D $dbh->selectrow_array("SELECT value FROM tab1 WHERE test=3D=
> 2");
> 
> However, what if I want to store a bunch of values into an array?
> 
>   my @vals =3D $dbh->?("SELECT value FROM tab1 WHERE test > 10");
> 
> What's the syntax I'm missing above?  Any help appreciated!


Glance over this for a minute (stolen from an example in perl cookbook):

   my $sth = $dbh->prepare( qq{select * from invoice} );
   $sth-> execute;

   while( (my @row) = $sth->fetchrow_array ) {
  print join(qq{, }, map {defined $_ ? $_ : qq{(null)} } @row, qq{\n};
   }


-- 
 Any technology distinguishable from magic is insufficiently advanced.
 TopQuark Software & Serv.  Contract programmer, server bum.
 [EMAIL PROTECTED]Give up Spammers; I use procmail.


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: Perl DBI -- How to select all returned values into an array

2001-08-25 Thread Paul DuBois

At 10:07 AM -0700 8/24/01, Katherine Porter wrote:
>For single values I usually use this DBI function and query:
>
>   my $val =3D $dbh->selectrow_array("SELECT value FROM tab1 WHERE test=3D=
>2");
>
>However, what if I want to store a bunch of values into an array?
>
>   my @vals =3D $dbh->?("SELECT value FROM tab1 WHERE test > 10");
>
>What's the syntax I'm missing above?  Any help appreciated!
>
>[.kate]


my $ref = $dbh->selectcol_arrayref (single-column query);
my @val = (defined ($ref) ? @{$ref} : () );

-- 
Paul DuBois, [EMAIL PROTECTED]

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: Perl DBI -- How to select all returned values into an array

2001-08-25 Thread Katherine Porter

For single values I usually use this DBI function and query:

  my $val =3D $dbh->selectrow_array("SELECT value FROM tab1 WHERE test=3D=
2");

However, what if I want to store a bunch of values into an array?

  my @vals =3D $dbh->?("SELECT value FROM tab1 WHERE test > 10");

What's the syntax I'm missing above?  Any help appreciated!

[.kate]





___
Visit http://www.visto.com.
Find out  how companies are linking mobile users to the 
enterprise with Visto.


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: Perl DBI to MySQL -- Passing info to query

2001-07-11 Thread Ilya Martynov


r> I was not aware of placeholders, and the benifits of using them instead of
r> using $dbh->quote(). It doesnt make sence that the DBI version of quote isnt
r> as thorough as having the code behind placeholding do it.

I'm not DBI guru but I've seen that quote() doesn't quote some data
correctly. Replacing it with placeholders fixed a problem. BTW fact
that quote is not releable is mentioned in DBI docs (perldoc
DBI). This is quote from there:

   Quote will probably not be able to deal with all pos-
   sible input (such as binary data or data containing
   newlines), and is not related in any way with escaping
   or quoting shell meta-characters. There is no need to
   quote values being used with the Placeholders and Bind
   Values entry elsewhere in this document.

r> But anyhow, I have
r> a few questions as to how this works. Here is an example from the Perl
r> DBH::mysql docs:

r> my @names = ['Flaherty', 'Jones', 'Smith'];
r> my $sth = $dbh->prepare("UPDATE contact
r>  SET phone = '555-1212'
r>  WHERE last_name = ?");
r> $sth->execute(@names);
r> $sth->finish;

Where did you found this example? I've not found it neither in man DBI
nor in man DBD::mysql.

AFAIK this example is just incorrect. For each placeholder you pass to
'execute' only one single scalar. Check man DBI chapter (Placeholders
and Bind Values) for info on placeholders usage. It has some examples.

-- 
 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| Ilya Martynov (http://martynov.org/)|
| GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80  E4AE BE1A 53EB 323B DEE6 |
| AGAVA Software Company (http://www.agava.com/)  |
 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: Perl DBI to MySQL -- Passing info to query

2001-07-10 Thread havoc

That would not be true.

You'd receive a message stating that you had one placeholder, but you
were passing 3 arugments, and it script would die on the error.

havoc

ryc wrote:
> 
> I was not aware of placeholders, and the benifits of using them instead of
> using $dbh->quote(). It doesnt make sence that the DBI version of quote isnt
> as thorough as having the code behind placeholding do it. But anyhow, I have
> a few questions as to how this works. Here is an example from the Perl
> DBH::mysql docs:
> 
> my @names = ['Flaherty', 'Jones', 'Smith'];
> my $sth = $dbh->prepare("UPDATE contact
>  SET phone = '555-1212'
>  WHERE last_name = ?");
> $sth->execute(@names);
> $sth->finish;
> 
> So most likely this query will return 3 rows, each corresponding to the last
> names contained in the array. Does this mean you can not use more than one
> place holder per query? What if the 'WHERE' statement was "WHERE last_name =
> ? AND first_name = ?". So you do an execute like this:
> $sth->execute(@lnames,@fnames) ... This would not work because as far as the
> execute function is concerned, these two arrays are the same (if you want to
> pass them as seperate arguments you must pass references rather than the
> object itself). Anyhow one how placeholders for multiple variables can be
> used? Thanks.
> 
> ryan
> 
> > r> Seems that you are not taking advantage of Perl. This is what you can
> do:
> >
> > No, he is taking advantage of placeholders. It is much better to use
> > placeholder for value substitution that substitute values directly
> > into query with Perl because there is no need to escape values (do you
> > know that $dbh->quote doesn't quote reliably?) and $sth can be reused
> > for simular queries (which can give perfomance gain on some SQL
> > databases).
> >
> > However usually placeholders can be used only for value
> > substitutuion. 'DESC' cannot be substituted since it is a part of
> > query.
> >
> > r> $parentid = x;
> > r> $orderby = 'DESC';
> > r>my $sth = $dbh -> prepare (qq{
> > r>  SELECT message.name, contents, user.name, message.id
> > r>  FROM message, user
> > r>  WHERE folder='N' and parentid=$parentid
> > r>  GROUP BY message.id
> > r>  ORDER BY time $orderby
> > r>  }) || die $dbh->errstr;
> >
> > r> You can put any variable inside the string... Note that I changed the
> q{
> > r> ... } to qq{ ... }
> >
> > r> $string = q{ string } is the same as $string = 'string';
> > r> $string = qq{ string } is the same as $string = "string";
> >
> > r> Note that variables inside of strings enclosed by '' will not be
> translated,
> > r> only strings enclosed by "" (or qq{} =) ).
> >
> > --
> >  -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
> > | Ilya Martynov (http://martynov.org/)
> |
> > | GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80  E4AE BE1A 53EB 323B DEE6
> |
> > | AGAVA Software Company (http://www.agava.com/)
> |
> >  -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
> >
> > -
> > Before posting, please check:
> >http://www.mysql.com/manual.php   (the manual)
> >http://lists.mysql.com/   (the list archive)
> >
> > To request this thread, e-mail <[EMAIL PROTECTED]>
> > To unsubscribe, e-mail <[EMAIL PROTECTED]>
> > Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
> >
> 
> -
> Before posting, please check:
>http://www.mysql.com/manual.php   (the manual)
>http://lists.mysql.com/   (the list archive)
> 
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail 
><[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

-- 
*===| http://bigpig.org/
*===|
*===| It's about Freedom!
|

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: Perl DBI to MySQL -- Passing info to query

2001-07-10 Thread ryc

I was not aware of placeholders, and the benifits of using them instead of
using $dbh->quote(). It doesnt make sence that the DBI version of quote isnt
as thorough as having the code behind placeholding do it. But anyhow, I have
a few questions as to how this works. Here is an example from the Perl
DBH::mysql docs:

my @names = ['Flaherty', 'Jones', 'Smith'];
my $sth = $dbh->prepare("UPDATE contact
 SET phone = '555-1212'
 WHERE last_name = ?");
$sth->execute(@names);
$sth->finish;

So most likely this query will return 3 rows, each corresponding to the last
names contained in the array. Does this mean you can not use more than one
place holder per query? What if the 'WHERE' statement was "WHERE last_name =
? AND first_name = ?". So you do an execute like this:
$sth->execute(@lnames,@fnames) ... This would not work because as far as the
execute function is concerned, these two arrays are the same (if you want to
pass them as seperate arguments you must pass references rather than the
object itself). Anyhow one how placeholders for multiple variables can be
used? Thanks.

ryan

> r> Seems that you are not taking advantage of Perl. This is what you can
do:
>
> No, he is taking advantage of placeholders. It is much better to use
> placeholder for value substitution that substitute values directly
> into query with Perl because there is no need to escape values (do you
> know that $dbh->quote doesn't quote reliably?) and $sth can be reused
> for simular queries (which can give perfomance gain on some SQL
> databases).
>
> However usually placeholders can be used only for value
> substitutuion. 'DESC' cannot be substituted since it is a part of
> query.
>
> r> $parentid = x;
> r> $orderby = 'DESC';
> r>my $sth = $dbh -> prepare (qq{
> r>  SELECT message.name, contents, user.name, message.id
> r>  FROM message, user
> r>  WHERE folder='N' and parentid=$parentid
> r>  GROUP BY message.id
> r>  ORDER BY time $orderby
> r>  }) || die $dbh->errstr;
>
> r> You can put any variable inside the string... Note that I changed the
q{
> r> ... } to qq{ ... }
>
> r> $string = q{ string } is the same as $string = 'string';
> r> $string = qq{ string } is the same as $string = "string";
>
> r> Note that variables inside of strings enclosed by '' will not be
translated,
> r> only strings enclosed by "" (or qq{} =) ).
>
> --
>  -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
> | Ilya Martynov (http://martynov.org/)
|
> | GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80  E4AE BE1A 53EB 323B DEE6
|
> | AGAVA Software Company (http://www.agava.com/)
|
>  -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
>
> -
> Before posting, please check:
>http://www.mysql.com/manual.php   (the manual)
>http://lists.mysql.com/   (the list archive)
>
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail <[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
>


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: Perl DBI to MySQL -- Passing info to query

2001-07-10 Thread Ilya Martynov


r> Seems that you are not taking advantage of Perl. This is what you can do:

No, he is taking advantage of placeholders. It is much better to use
placeholder for value substitution that substitute values directly
into query with Perl because there is no need to escape values (do you
know that $dbh->quote doesn't quote reliably?) and $sth can be reused
for simular queries (which can give perfomance gain on some SQL
databases).

However usually placeholders can be used only for value
substitutuion. 'DESC' cannot be substituted since it is a part of
query.

r> $parentid = x;
r> $orderby = 'DESC';
r>my $sth = $dbh -> prepare (qq{
r>  SELECT message.name, contents, user.name, message.id
r>  FROM message, user
r>  WHERE folder='N' and parentid=$parentid
r>  GROUP BY message.id
r>  ORDER BY time $orderby
r>  }) || die $dbh->errstr;

r> You can put any variable inside the string... Note that I changed the q{
r> ... } to qq{ ... }

r> $string = q{ string } is the same as $string = 'string';
r> $string = qq{ string } is the same as $string = "string";

r> Note that variables inside of strings enclosed by '' will not be translated,
r> only strings enclosed by "" (or qq{} =) ).

-- 
 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| Ilya Martynov (http://martynov.org/)|
| GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80  E4AE BE1A 53EB 323B DEE6 |
| AGAVA Software Company (http://www.agava.com/)  |
 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: Perl DBI to MySQL -- Passing info to query

2001-07-09 Thread ryc

Seems that you are not taking advantage of Perl. This is what you can do:

$parentid = x;
$orderby = 'DESC';
   my $sth = $dbh -> prepare (qq{
 SELECT message.name, contents, user.name, message.id
 FROM message, user
 WHERE folder='N' and parentid=$parentid
 GROUP BY message.id
 ORDER BY time $orderby
 }) || die $dbh->errstr;

You can put any variable inside the string... Note that I changed the q{
... } to qq{ ... }

$string = q{ string } is the same as $string = 'string';
$string = qq{ string } is the same as $string = "string";

Note that variables inside of strings enclosed by '' will not be translated,
only strings enclosed by "" (or qq{} =) ).

Hope that helps. For more info goto www.perl.com

ryan


> I'm having some trouble passing some information from my Perl script to
> the DBI query interface.
>
> A short version of my query would look like:
>
>   my $sth = $dbh -> prepare (q{
> SELECT message.name, contents, user.name, message.id
> FROM message, user
> WHERE folder='N' and parentid=?
> GROUP BY message.id
> ORDER BY time ?
> }) || die $dbh->errstr;
>
> Then, I'm calling the query:
>
>   $sth->execute($parent, "DESC");
>
> The "DESC" is being ignored. I can hard-code it into the query and it
> works fine. The closest I've been able to achive in having the query
> recognize the second ? is to have it crash with an error reporing that
> it's there, but doing nothing about it
>
> go figure.
>
> any help is greatly appreciated.
> --
> *===| http://bigpig.org/
> *===|
> *===| It's about Freedom!
> |
>
> -
> Before posting, please check:
>http://www.mysql.com/manual.php   (the manual)
>http://lists.mysql.com/   (the list archive)
>
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail <[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
>


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: Perl DBI to MySQL -- Passing info to query

2001-07-09 Thread Joshua J. Kugler

Simple answer: you can't do that.

The ? is only for WHERE parameters.  You need to have two differnt queries 
(or one query, and concatanate the desired sort command).

j- k-

On Monday 09 July 2001 21:13, havoc wrote:
> I'm having some trouble passing some information from my Perl script to
> the DBI query interface.
>
> A short version of my query would look like:
>
>   my $sth = $dbh -> prepare (q{
> SELECT message.name, contents, user.name, message.id
> FROM message, user
> WHERE folder='N' and parentid=?
> GROUP BY message.id
> ORDER BY time ?
> }) || die $dbh->errstr;
>
> Then, I'm calling the query:
>
>   $sth->execute($parent, "DESC");
>
> The "DESC" is being ignored. I can hard-code it into the query and it
> works fine. The closest I've been able to achive in having the query
> recognize the second ? is to have it crash with an error reporing that
> it's there, but doing nothing about it
>
> go figure.
>
> any help is greatly appreciated.

-- 
Joshua Kugler, Information Services Director
Associated Students of the University of Alaska Fairbanks
[EMAIL PROTECTED], 907-474-7601


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: Perl DBI Error 19

2001-06-27 Thread Gerald Clark

Your inner loop usage of $sth overwrites the result set of the outer loop.
Use a different variable.

Hannes Niedner wrote:

> I am having trouble with DBI. I wrote a little script that should update
> fields in one table (uid_test) based on values in another table (merge). I
> updates one row and then dies with:
> 
>  os prompt: blah blah
> 
> 1   1011877 101
> Error during processing for table uid_test
> 
> Error 19 (fetch() without execute())
> 
> The selected values (primary_id, other_id) are both INT(12) and so are the
> fields of the target table (superceded_by, uid_new).
> 
> Please have a look at the Perl code snippet below. As I said it works for
> the first row. BTW if there is pure sql code that would do the job, I would
> be delighted to learn about.
> 
> Thanks Hannes
> 
> 
> 
> -snippet-
> #issue query
> $sth = $dbh->prepare ( "SELECT primary_id, other_id
> FROM merge
> ORDER BY other_id"
>  ) or &bail_out ("Cannot prepare query from merge");
> $sth->execute () or &bail_out ("Cannot execute query from merge");
> 
> while (@ary = $sth->fetchrow_array ()) {
> $counter++;
> my ($primary_id) = $ary[0];
> my ($other_id) = $ary[1];
> print "$counter\t$primary_id\t$other_id\n";
> 
> #update the data in the target table
> $sth = $dbh->prepare ( "UPDATE $table_name
> SET superceded_by=$primary_id, status=\'1\',
> time=null
> WHERE uid_new=$other_id"
>  ) or &bail_out ("Cannot prepare sql (UPDATE
> $table_name)!");
> $sth->execute () or &bail_out ("Cannot execute sql(UPDATE
> $table_name)!"); 
>   
> }
> 
> if (!defined($DBI::err)) {
> print "$counter sequences retrieved from table merge, cleaned out
> and successfully updated in table niedner.$table_name.\n";
> }else {&bail_out ("Error during processing for table $table_name\n");
> }
> 
> 
> #clean up
> $sth->finish () or &bail_out ("Cannot finish query from database");
> $dbh->disconnect () or &bail_out ("Cannot disconnect from database");
> exit (0)
> --snippet end
> 
> 
> -
> Before posting, please check:
>http://www.mysql.com/manual.php   (the manual)
>http://lists.mysql.com/   (the list archive)
> 
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail 
><[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php


-- 
Gerald L. Clark
[EMAIL PROTECTED]


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: Perl DBI Error 19 -solved

2001-06-25 Thread Hannes Niedner

Just if somebody is interested:

I solved the mystery with Error 19. All I needed to do was introducing a
second statement handle for the update query.
(BTW, the script runs probably faster using '$sth = $dbh->do' instead of
'$sth = $dbh->prepare', followed by '$sth = $dbh->execute').

Hannes 


On 6/24/01 4:05 AM, "Hannes Niedner" <[EMAIL PROTECTED]> wrote:

> I am having trouble with DBI. I wrote a little script that should update
> fields in one table (uid_test) based on values in another table (merge). I
> updates one row and then dies with:
> 
> os prompt: blah blah
> 
> 1   1011877 101
> Error during processing for table uid_test
> 
> Error 19 (fetch() without execute())
> 
> The selected values (primary_id, other_id) are both INT(12) and so are the
> fields of the target table (superceded_by, uid_new).
> 
> Please have a look at the Perl code snippet below. As I said it works for
> the first row. BTW if there is pure sql code that would do the job, I would
> be delighted to learn about.
> 
> Thanks Hannes
> 
> 
> 
> -snippet-
>   #issue query
>   $sth = $dbh->prepare ( "SELECT primary_id, other_id
>   FROM merge
>   ORDER BY other_id"
>) or &bail_out ("Cannot prepare query from merge");
>   $sth->execute () or &bail_out ("Cannot execute query from merge");
> 
>   while (@ary = $sth->fetchrow_array ()) {
>   $counter++;
>   my ($primary_id) = $ary[0];
>   my ($other_id) = $ary[1];
>   print "$counter\t$primary_id\t$other_id\n";
>   
>   #update the data in the target table
>   $sth = $dbh->prepare ( "UPDATE $table_name
>   SET superceded_by=$primary_id, status=\'1\',
> time=null
>   WHERE uid_new=$other_id"
>) or &bail_out ("Cannot prepare sql (UPDATE
> $table_name)!");
>   $sth->execute () or &bail_out ("Cannot execute sql(UPDATE
> $table_name)!"); 
> 
>   }
> 
>   if (!defined($DBI::err)) {
>   print "$counter sequences retrieved from table merge, cleaned out
> and successfully updated in table niedner.$table_name.\n";
>   }else {&bail_out ("Error during processing for table $table_name\n");
>   }
>   
> 
>   #clean up
>   $sth->finish () or &bail_out ("Cannot finish query from database");
>   $dbh->disconnect () or &bail_out ("Cannot disconnect from database");
>   exit (0)
> --snippet end
> 
> 
> -
> Before posting, please check:
>  http://www.mysql.com/manual.php   (the manual)
>  http://lists.mysql.com/   (the list archive)
> 
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail
> <[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
> 


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: Perl DBI and rollback()

2001-06-23 Thread Ilya Martynov


TEG> Batara Kesuma <[EMAIL PROTECTED]> writes:
>> Hello,
>> 
>> I think it might not be a right mailing list for this question, but I
>> don't know where else should I post it. 
>> 
>> If I run Perl DBI's $dbh->connect() without $dbh->disconnect(), MySQL (or
>> is it the Perl DBI module) will run rollback() with an error message:
>> Issuing rollback() for database handle being DESTROY'd without explicit
>> disconnect().
>> 
>> My question is, is there any bad effect for MySQL to run the rollback()?
>> (ex. MySQL server will become slower, MySQL server will crash, etc).

TEG> Well, you've just lost the effects of your operation...

Only if AutoCommit is off and table type support transactions.

-- 
 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| Ilya Martynov (http://martynov.org/)|
| GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80  E4AE BE1A 53EB 323B DEE6 |
| AGAVA Software Company (http://www.agava.com/)  |
 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: Perl DBI and rollback()

2001-06-22 Thread Paul DuBois

At 12:17 PM -0400 6/22/01, Trond Eivind Glomsrød wrote:
>Batara Kesuma <[EMAIL PROTECTED]> writes:
>
>>  Hello,
>>
>>  I think it might not be a right mailing list for this question, but I
>>  don't know where else should I post it.
>>
>>  If I run Perl DBI's $dbh->connect() without $dbh->disconnect(), MySQL (or
>>  is it the Perl DBI module) will run rollback() with an error message:
>>  Issuing rollback() for database handle being DESTROY'd without explicit
>>  disconnect().
>>
>>  My question is, is there any bad effect for MySQL to run the rollback()?
>>  (ex. MySQL server will become slower, MySQL server will crash, etc).
>
>Well, you've just lost the effects of your operation...

And this is different from DBI issuing it automatically ?

>
>--
>Trond Eivind Glomsrød
>Red Hat, Inc.


--
Paul DuBois, [EMAIL PROTECTED]

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: Perl DBI and rollback()

2001-06-22 Thread Trond Eivind Glomsrød

Batara Kesuma <[EMAIL PROTECTED]> writes:

> Hello,
> 
> I think it might not be a right mailing list for this question, but I
> don't know where else should I post it. 
> 
> If I run Perl DBI's $dbh->connect() without $dbh->disconnect(), MySQL (or
> is it the Perl DBI module) will run rollback() with an error message:
> Issuing rollback() for database handle being DESTROY'd without explicit
> disconnect().
> 
> My question is, is there any bad effect for MySQL to run the rollback()?
> (ex. MySQL server will become slower, MySQL server will crash, etc).

Well, you've just lost the effects of your operation...

-- 
Trond Eivind Glomsrød
Red Hat, Inc.

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: Perl DBI

2001-02-16 Thread Eric Fitzgerald

Here is what I would do.


There is always a database on every mysql installation called "mysql"

This database is where your permissions tables and such are stored.

Connect initially to that database.  Then, try to create the new database.
If you get an error back, prompt the user, rinse and repeat.

Your connection string should look something like this:
$dbh =
DBI->connect('DBI:mysql:mysql;host=somehost','someuser','somepassword');

Of coarse, you could always connect to the mysql database and get a list of
databases, and not have to expect an error back from mysql on connection...

- Original Message -
From: "John Tsangaris" <[EMAIL PROTECTED]>
To: "Eric Fitzgerald" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Friday, February 16, 2001 4:46 PM
Subject: RE: Perl DBI


> Hi, Eric.
>
> What I'm trying to do is have my install program check to see if a
database
> of a certain name exists, if it does then the install needs to create
> another one (using a name given by the user), if not then it needs to
create
> it with the original name.
>
> But I cannot figure out how to connect to mysql without already having a
> database setup.
>
> I'll use dbtemp as an example db.
>
> I can try to connect to dbtemp and if it successful, I know it exists.  So
I
> prompt the user to enter another db name.  I can then check if this exists
> and if it doesn't I can use the dbi to create the new db WHILE I am still
> connected to dbtemp.
>
> If dbtemp does not exist I need to create it.  The problem is dbi needs to
> connect to a database even to create another one.  So what/how do I
connect
> to initially to create that first database?
>
> I realize, for geeks (myself included), that you could simply create the
db
> manually and then install the program.. but the program is to be usable by
> the layperson.. which means that there is a chance they don't know
anything
> about mysql other than the guy on tech support said it's installed on the
> server.
>
> How do I connect to mysql without connecting to a database?
>
>
> John
>
> -Original Message-
> From: Eric Fitzgerald [mailto:[EMAIL PROTECTED]]
> Sent: Friday, February 16, 2001 1:21 PM
> To: John Tsangaris; [EMAIL PROTECTED]
> Subject: Re: Perl DBI
>
>
> Connect to the mysql database if you have access.  It always exists.
>
> - Original Message -
> From: "John Tsangaris" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Friday, February 16, 2001 1:58 PM
> Subject: Perl DBI
>
>
> > Is it possible to connect to mysql without connecting directly to a
> > database, check to see if a particular database exists, and if it
doesn't
> > exist create it?
> >
> > I have not been able to find a way of connecting to mysql without having
a
> > database already (I want perl to be able to make the db.. not have it
> > already made before hand.)
> >
> > tia
> >
> > John
> >
> >
> > -
> > Before posting, please check:
> >http://www.mysql.com/manual.php   (the manual)
> >http://lists.mysql.com/   (the list archive)
> >
> > To request this thread, e-mail <[EMAIL PROTECTED]>
> > To unsubscribe, e-mail
<[EMAIL PROTECTED]>
> > Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
> >
> >
> >
>
>
>


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




RE: Perl DBI

2001-02-16 Thread John Tsangaris

Hi, Eric.

What I'm trying to do is have my install program check to see if a database
of a certain name exists, if it does then the install needs to create
another one (using a name given by the user), if not then it needs to create
it with the original name.

But I cannot figure out how to connect to mysql without already having a
database setup.

I'll use dbtemp as an example db.

I can try to connect to dbtemp and if it successful, I know it exists.  So I
prompt the user to enter another db name.  I can then check if this exists
and if it doesn't I can use the dbi to create the new db WHILE I am still
connected to dbtemp.

If dbtemp does not exist I need to create it.  The problem is dbi needs to
connect to a database even to create another one.  So what/how do I connect
to initially to create that first database?

I realize, for geeks (myself included), that you could simply create the db
manually and then install the program.. but the program is to be usable by
the layperson.. which means that there is a chance they don't know anything
about mysql other than the guy on tech support said it's installed on the
server.

How do I connect to mysql without connecting to a database?


John

-Original Message-
From: Eric Fitzgerald [mailto:[EMAIL PROTECTED]]
Sent: Friday, February 16, 2001 1:21 PM
To: John Tsangaris; [EMAIL PROTECTED]
Subject: Re: Perl DBI


Connect to the mysql database if you have access.  It always exists.

- Original Message -
From: "John Tsangaris" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, February 16, 2001 1:58 PM
Subject: Perl DBI


> Is it possible to connect to mysql without connecting directly to a
> database, check to see if a particular database exists, and if it doesn't
> exist create it?
>
> I have not been able to find a way of connecting to mysql without having a
> database already (I want perl to be able to make the db.. not have it
> already made before hand.)
>
> tia
>
> John
>
>
> -
> Before posting, please check:
>http://www.mysql.com/manual.php   (the manual)
>http://lists.mysql.com/   (the list archive)
>
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail <[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
>
>
>


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: Perl DBI

2001-02-16 Thread Eric Fitzgerald

Connect to the mysql database if you have access.  It always exists.

- Original Message -
From: "John Tsangaris" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, February 16, 2001 1:58 PM
Subject: Perl DBI


> Is it possible to connect to mysql without connecting directly to a
> database, check to see if a particular database exists, and if it doesn't
> exist create it?
>
> I have not been able to find a way of connecting to mysql without having a
> database already (I want perl to be able to make the db.. not have it
> already made before hand.)
>
> tia
>
> John
>
>
> -
> Before posting, please check:
>http://www.mysql.com/manual.php   (the manual)
>http://lists.mysql.com/   (the list archive)
>
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail <[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
>
>
>


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php