[EMAIL PROTECTED] wrote:
Hi all. My goal is to get a list of all field names and data types for
those fields in any given table in a mysql database. From reading the
DBI documentation, the only way I've been able to do this is by
preparing and executing a query against a table first. Then I
It is much more easily portable.
Suppose you have a real query:
select a.foo, b.bar.c.baz
from
a, b, c
where .
The 0= 1 method works for that too. Contrast that with parsing the
from clause and the where clause to create a tabel catalog query. Yuk.
How can you gaurantee all DB engines
Matthew Persico wrote:
So now I need one for every database?
For every database you need to support yes, not all engines will return
the exact same data with a query if no results and that also not in the
same format.
But each database is 00% gauranteed to support what it documents it
Reidy, Ron wrote:
No, I do not know you are a DBA; maybe YOU cannot describe the problem
well enough.
-Original Message-
From: Drozdowski, Catharine [mailto:[EMAIL PROTECTED]
Sent: Tuesday, May 23, 2006 10:11 AM
To: Reidy, Ron; dbi-users@perl.org
Subject: RE: Identify PID for
Reidy, Ron wrote:
1. Look in the data dictionary
2. Select from the table and trap the appropriate error code
-Original Message-
From: Loo, Peter # PHX [mailto:[EMAIL PROTECTED]
Sent: Thursday, April 27, 2006 4:33 PM
To: List - DBI users
Subject: Checking if a table exist
Hi All,
Tim Bunce wrote:
On Wed, Apr 12, 2006 at 04:33:39PM +0200, Dr.Ruud wrote:
Jeffrey Seger schreef:
perl -MData::Dumper -e' print Dumper @INC'
Alternative:
perl -MData::Dumper -e' print Data::Dumper-Dump([EMAIL PROTECTED], [qw(*INC)])'
Oi, why not much cleaner (code and output):
perl
Hello list,
I'm about to go nuts trying to connect to Microsoft SQL Server 2000 from
a linux machine.
I'll pay $20 to the first person who can get me over this last hump,
seriously I'll paypal it to you, maybe more if the solution is had
quickly. No joke, I will pay :)
Here's what I have:
Sham Prasad wrote:
Hi all,
Hello,
I have a bugzilla database running on mysql. If you are aware of
bugzilla, it has a table called attachments. what i am trying to do
is get the attachments of all the bugs having attachment/s into a
directory.
for example there is a bug with a attachment
[EMAIL PROTECTED] wrote:
Hi.
Hello,
Solved after I posted.
Surround $email with 's.
As in '$email'.
Close, but this is a gun pointed at your head :)
You either need to $dbh-quote() it or do the bind value/placeholder
(see `perldoc DBI` for details of both)
Is there any way to tell if my package is being tested automatically
under CPAN::Testers? Here's the situation:
I've never used that module but this should work:
if(exists $INC{'CPAN/Testers.pm'}) {
print I am probably running under CPAN::Testers\n;
}
else {
print I am
Peter J. Holzer wrote:
or selectall_arrayhashref?
Anyway, I rather frequently find that the most natural way to
represent a query result is an array of hashes: Each row is hashref, but
the the rows are in an array(ref) so that the order is preserved, and
the columns can be accessed by name.
Can't load =
'/usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/auto/DBD/Oracle/O=
racle.so'=20
for module DBD::Oracle: libclntsh.so.10.1: cannot open shared object =
file:=20
No such file or directory
I imagine your web server does not have permissions to the
wernerus sebastien wrote:
Tim, I made the changes you suggested. Here is the code:
---
package MySubDBI;
...
package Main;
try:
package main; #IE lowercase M, not Main..
Also be sure to:
use strict;
use warnings;
in each package as that will likley tell
listmail wrote:
Well I'm not seeing why a number of arrays that each point to arrays
could not be consider a matrix of arrays when considering one definition
of the word matrix Something resembling such an array, as in the
regular formation of elements into columns and rows. I dunno, i'm
Also very convoluted, all of that can be done with:
my $results = $dbh-selectall_arrayref($sql); # if you only want
to
process a certain amount just LIMIT in your $sql...
I appreciate the response. I tested selectall_arrayref and as I
expected, irregardless of the number of rows
[EMAIL PROTECTED] wrote:
#Here's an example which shows what I am trying to accomplish. If I
can determine the number of rows before pushing the data, this can
simply things for #me when processing the data throught my scripts.
#
use warnings;
use strict;
Good good :)
use DBI;
use
moma wrote:
Hi,
Hello,
i am using postgresql 7.4.7 on an ubuntu box, perl 5.8.4 and DBI version
1.46 with DBD::Pg version 1.32.
i can create tables from psql with an $ in the middle of it, e.g. create
table foo$bar (id integer);
That seems like a bad bad bad bad idea because how can you
folks :)
HTH :) Lee.M - JupiterHost.Net
Ron Savage wrote:
On Thu, 07 Jul 2005 11:38:06 +1000, Daniel Kasak wrote:
Hi Daniel
my $sth = $dbh-prepate( set dateformat dmy );
What am I doing wrong?
probably prepate is not a function, I think you mean prepare
Does that exact query work via CLI interface (IE is the query bad)
:)
Lee.M JupiterHost.Net
a) We are using Oracle 8i DB.
The query (or the DBMS) takes only 6 seconds
to return data to Perl.
How did you determine this? I think you're just assuming that.
c) So we conclude that it is mainly an issue with fetchrow especially when
the number of records are high. We tried other possible
After that did not work, they directed me to your list, in the hopes you could
give me some assistance with how to resolve this. Any help you can offer is
much appreicated.
Er, you may want to not show your passwords on a public list...
They were right, its not a cPanel issue. Have you upgraded
$dbh-do(INSERT INTO t (col1, ...) SELECT col1, ... FROM t2 WHERE x
= '$element');
Oi SQL injection warning! Red lights and sirens - don't do that!!
'$element' is supper dangerouse, evil evil evil
either $dbh-quote it or use ? in your prepare/execute dance:
$dbh-do( 'INSERT INTO t
Thilo Planz wrote:
I make a page that returns the result of a select statement in Perl
and DBI, but a lot of rows are returned, there is a way to page the
result ?
Yes, there are several modules for this.
The best one (easy to use, all the functions you need in one place)
I've used is
Hernan Arredondo wrote:
Hi all,
Hello,
I make a page that returns the result of a select statement in Perl
and DBI, but a lot of rows are returned, there is a way to page the
result ?
Yes, there are several modules for this.
The best one (easy to use, all the functions you need in one place)
Moosmann, James wrote:
Nope, same results, Here is a simple example:
Is the syntax invalid?
use DBI;
my $dbh = DBI-connect('dbi:ODBC:somedb','','');
my $qs = $dbh-quote( SELECT \Rows returned: \ );
Why are you quoting the entire query as a string?
$dbh-do($qs);
Use a valid query:
$dbh-do(SELECT
Moosmann, James wrote:
Lee,
Hello,
The select statement is very valid and so is:
SELECT 'Hello World!' as 'My first SQL Statement'
-or-
SELECT answer = 2+3
Really, try it.
ok, but if you $dbh-quote() it, it becomes something like:
'SELECT \'Hello World!\' as \'My first SQL Statement\''
all the applications of my company work with apache Perl oracle,I want to know
as it is the future of the Perl in the world and if we go by the correct way,
because the directors of the company think that no.
as it is its use in the world.
I can't speak for others but look at the history and
Oscar Gomez wrote:
all the applications of my company work with apache Perl oracle,I
want to know as it is the future of the Perl in the world and if we
Those will be developed , supported, and industry standard mission
critical safe.
go by the correct way, because the directors of the
the last uid, you can add DESC or something similar
to reverse the results. But you'd need to see your DB vendor's website
for more details.
HTH :)
Lee.M - JupiterHost.Net
Licensing may not be an issue with mysql but it is an issue with commercial databases.
I use Informix with hundreds of users accessing the database for extremely short queries from a GUI. I cannot afford to have them connected constantly, I would have to spent $100,000 per server in licensing.
Sterin, Ilya (I.) wrote:
Commercial databases have commercial support behind them, that's what is driving it.
Most non-IT companies, do not want to invest in internal departments that are
responsible for supporting an open source software product. Until a giant like IBM,
HP, or similar puts
Sterin, Ilya (I.) wrote:
I know Tim will kill me for this OT stuff:-)
Tim's a pretty cool guy it seems, but maybe we should let the horse die :)
I feel the likely hood of the economy changing and causing
major issues
for big companies is way more likely than the open source
community to
get you started :)
perldoc DBI
perldoc CGI
HTH
Lee.M - JupiterHost.Net
I'm actually looking for the source code for execute() (IE sub execute {
.. }), do() and quote() are in DBI.pm, prepare() is in DBD/mysql.pm but
execute in neither.
The source code for execute is in dbd_st_execute() in dbdimp.c, and if you want
to know how the quoting is done, you will need to
essencially run:
INSERT INTO Stuff (Id,Foo) VALUES (NULL,'foo');
INSERT INTO Stuff (Id,Foo) VALUES (NULL,'bar');
INSERT INTO Stuff (Id,Foo) VALUES (NULL,'baz');
since do() does the prepare and execute for you.
correct?
TIA
Lee.M - JupiterHost.Net
($foo), $dbh-quote($bar), $dbh-quote($baz)
) or die
or
$dbh-do(
'INSERT INTO Stuff (Id,Foo,Bar,Baz) VALUES (NULL,?,?,?)',
undef,
$foo, $bar, $baz
) or die
Thanks!
Lee.M - JupiterHost.Net
Ronald J Kimball wrote:
JupiterHost.Net [mailto:[EMAIL PROTECTED] wrote:
I found do() and quote() in DBI.pm, prepare() in DBD::mysql, but I
couldn't find execute() - I wanted to see how it does the quoting
exactly (for binary data) -
Anyone know where execute() is?
All of these are covered
Anyone ever do this before?
JupiterHost.Net wrote:
Hello DBI folks!
If I have a column that is binary and data that is binary do I simply
$dbh-quote() it on an insert?
IE
my $binary_content = get_binary_stuff();
my $binary_content_Q = $dbh-quote($binary_content);
$dbh-do(UPDATE MyStuff SET
appreciate the input :)
On Mon, 2004-05-10 at 14:18, JupiterHost.Net wrote:
Anyone ever do this before?
JupiterHost.Net wrote:
Hello DBI folks!
If I have a column that is binary and data that is binary do I simply
$dbh-quote() it on an insert?
IE
my $binary_content = get_binary_stuff();
my
Andy Hassall wrote:
The general approach is to always use placeholders, and never directly
interpolate values into SQL statements. This should insulate you from
whatever encoding's needed. Constants in SQL are OK, but if you're putting
encoding as in quote()ing or encoding as in
Rudy Lippan wrote:
On Sat, 10 Apr 2004, JupiterHost.Net wrote:
Via the command line I can connect to MySQL and do what I want fine.
Via DBI I get the classic Can't connect to local MySQL server through
socket '/tmp/MySQL.sock' (2)
So MySQL seesmt to not be running but it is! The socket
/MySQL.soc (if so why)?
Tia :)
Lee.M - JupiterHost.Net
43 matches
Mail list logo