Discussion:
Use DBI quote without creating an object
(too old to reply)
Dan Muey
2003-12-11 18:53:35 UTC
Permalink
Howdy!

I'm creating some sql entries into a text file.

I'd like to use DBI's quote function without having to
connect to a database and without having to create my own!

Is that possible?

I've tried importing quote, doing DBI::quote, DBI::db::quote, and various versions of that.

Any ideas?

GOAL:
use DBI;
my $quoted_data = DBI->quote($data);

Instead of

use DBI;
my $dbh - DBI->connect(...)...;
my $quoted_data = $dbh->quote($data);


TIA

Dan
Bob Showalter
2003-12-11 19:12:09 UTC
Permalink
Dan Muey wrote:
> Howdy!
>
> I'm creating some sql entries into a text file.
>
> I'd like to use DBI's quote function without having to
> connect to a database and without having to create my own!
>
> Is that possible?
>
> I've tried importing quote, doing DBI::quote, DBI::db::quote, and
> various versions of that.
>
> Any ideas?
>
> GOAL:
> use DBI;
> my $quoted_data = DBI->quote($data);
>
> Instead of
>
> use DBI;
> my $dbh - DBI->connect(...)...;
> my $quoted_data = $dbh->quote($data);

use DBI;
print DBD::_::db->quote('Hello');

perldoc -m DBI
David
2003-12-11 19:47:43 UTC
Permalink
Bob Showalter wrote:

> use DBI;
> print DBD::_::db->quote('Hello');
>
> perldoc -m DBI

this does not work, you need:

[panda]# perl -MDBI -le 'print DBD::_::db::quote(1,"abcd")'

david
--
s,.*,<<,e,y,\n,,d,y,.s,10,,s
.ss.s.s...s.s....ss.....s.ss
s.sssss.sssss...s...s..s....
...s.ss..s.sss..ss.s....ss.s
s.sssss.s.ssss..ss.s....ss.s
..s..sss.sssss.ss.sss..ssss.
..sss....s.s....ss.s....ss.s

,....{4},"|?{*=}_'y!'+0!$&;"
,ge,y,!#:$_(-*[./<-@{-},b-t,
.y...,$~=q~=?,;^_#+?{~,,$~=~
y.!-&*-/:-@^_{}.a-t ().;s,;,
);,g,s,s,$~s,g,y,y,%,,g,eval
David
2003-12-11 19:49:41 UTC
Permalink
David wrote:

> Bob Showalter wrote:
>
>> use DBI;
>> print DBD::_::db->quote('Hello');
>>
>> perldoc -m DBI
>
> this does not work, you need:
>

sorry. i am wrong. your version works as well.

david
--
s,.*,<<,e,y,\n,,d,y,.s,10,,s
.ss.s.s...s.s....ss.....s.ss
s.sssss.sssss...s...s..s....
...s.ss..s.sss..ss.s....ss.s
s.sssss.s.ssss..ss.s....ss.s
..s..sss.sssss.ss.sss..ssss.
..sss....s.s....ss.s....ss.s

,....{4},"|?{*=}_'y!'+0!$&;"
,ge,y,!#:$_(-*[./<-@{-},b-t,
.y...,$~=q~=?,;^_#+?{~,,$~=~
y.!-&*-/:-@^_{}.a-t ().;s,;,
);,g,s,s,$~s,g,y,y,%,,g,eval
Daniel Staal
2003-12-11 19:20:00 UTC
Permalink
--As off Thursday, December 11, 2003 12:53 PM -0600, Dan Muey is
alleged to have said:

> I'd like to use DBI's quote function without having to
> connect to a database and without having to create my own!
>
> Is that possible?

--As for the rest, it is mine.

I would suspect it is not possible. You have a simple problem here:
what quote format does DBI need to use? The purpose of the quote
function is that each database needs a different quote format. If
you haven't connected to a database how can DBI know which you intend
to use?

The only thing I would try yet at this point would be importing the
DBD's (for your specific database) quote function (I'm assuming quote
is implemented in the obvious way) and using it directly, but I
wouldn't count on that working.

Either that or re-think your problem, so that you don't have to quote
it until you actually know which database you are using...

Daniel T. Staal

---------------------------------------------------------------
This email copyright the author. Unless otherwise noted, you
are expressly allowed to retransmit, quote, or otherwise use
the contents for non-commercial purposes. This copyright will
expire 5 years after the author's death, or in 30 years,
whichever is longer, unless such a period is in excess of
local copyright law.
---------------------------------------------------------------
Loading...