Function notation with mysql
Function notation with mysql
am 07.09.2007 11:40:54 von Lars Eighner
I'd like to work in perl, but it appears the Mysql module has been eaten by
DBI so it will no longer recognize funtion notation. Is there any
procedural-type library for interfacing with Mysql?
--
Lars Eighner
Countdown: 501 days to go.
What do you do when you're debranded?
Re: Function notation with mysql
am 07.09.2007 17:30:56 von Sherm Pendley
Lars Eighner writes:
> I'd like to work in perl, but it appears the Mysql module has been eaten by
> DBI so it will no longer recognize funtion notation. Is there any
> procedural-type library for interfacing with Mysql?
Why? Are you fraid your head will explode if you type "->" too many times?
sherm--
--
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net
Re: Function notation with mysql
am 07.09.2007 18:41:25 von Jim Cochrane
On 2007-09-07, Sherm Pendley wrote:
> Lars Eighner writes:
>
>> I'd like to work in perl, but it appears the Mysql module has been eaten by
>> DBI so it will no longer recognize funtion notation. Is there any
>> procedural-type library for interfacing with Mysql?
>
> Why? Are you fraid your head will explode if you type "->" too many times?
>
> sherm--
>
Maybe he has a repetitive motion syndrome, but only in finger number 4
(counting the thumb as finger # 1) of his right hand. :-)
--
Re: Function notation with mysql
am 07.09.2007 18:45:11 von Lars Eighner
In our last episode,
,
the lovely and talented Sherm Pendley
broadcast on comp.lang.perl.misc:
> Lars Eighner writes:
>> I'd like to work in perl, but it appears the Mysql module has been eaten by
>> DBI so it will no longer recognize funtion notation. Is there any
>> procedural-type library for interfacing with Mysql?
> Why? Are you fraid your head will explode if you type "->" too many times?
No, I am afraid of broken stuff that I cannot fix. Hey, like GUIs, objects
are fine if you want to do exactly what developers think you should want to
do exactly the way they think everyone should want to do them.
--
Lars Eighner
Countdown: 500 days to go.
What do you do when you're debranded?
Re: Function notation with mysql
am 07.09.2007 20:51:12 von xhoster
Lars Eighner wrote:
> In our last episode,
> ,
> the lovely and talented Sherm Pendley
> broadcast on comp.lang.perl.misc:
>
> > Lars Eighner writes:
>
> >> I'd like to work in perl, but it appears the Mysql module has been
> >> eaten by DBI so it will no longer recognize funtion notation. Is
> >> there any procedural-type library for interfacing with Mysql?
>
> > Why? Are you fraid your head will explode if you type "->" too many
> > times?
>
> No, I am afraid of broken stuff that I cannot fix. Hey, like GUIs,
> objects are fine if you want to do exactly what developers think you
> should want to do exactly the way they think everyone should want to do
> them.
You could always invoke the code thingies in subroutine form rather than
method form if that makes you happy, but I suspect you are just delight in
being unhappy.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
Re: Function notation with mysql
am 07.09.2007 21:03:13 von Keith Keller
On 2007-09-07, Lars Eighner wrote:
>
> No, I am afraid of broken stuff that I cannot fix. Hey, like GUIs, objects
> are fine if you want to do exactly what developers think you should want to
> do exactly the way they think everyone should want to do them.
I suppose this is true, but if you're simply generating queries, there
is only a small handful of methods you'll need to use (e.g., connect,
prepare, execute, fetch, do). Much of the rest of DBI is syntactic
sugar and convenience methods, which you can safely not use.
--keith
--
kkeller-usenet@wombat.san-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://www.therockgarden.ca/aolsfaq.txt
see X- headers for PGP signature information
Re: Function notation with mysql
am 07.09.2007 21:38:47 von Lars Eighner
In our last episode, , the
lovely and talented Keith Keller broadcast on comp.lang.perl.misc:
> On 2007-09-07, Lars Eighner wrote:
>>
>> No, I am afraid of broken stuff that I cannot fix. Hey, like GUIs, objects
>> are fine if you want to do exactly what developers think you should want to
>> do exactly the way they think everyone should want to do them.
> I suppose this is true, but if you're simply generating queries, there
> is only a small handful of methods you'll need to use (e.g., connect,
> prepare, execute, fetch, do). Much of the rest of DBI is syntactic
> sugar and convenience methods, which you can safely not use.
Well, I have rethought this, and decided that I can probably write the
functions I need using backtick calls to the mysql client. I did something
rather rash and actually read man mysql, discovering that if I don't call it
interactively, I don't have to try to parse the ASCII tables.
--
Lars Eighner
Countdown: 500 days to go.
What do you do when you're debranded?
Re: Function notation with mysql
am 07.09.2007 21:51:15 von glex_no-spam
Lars Eighner wrote:
[...]
> Well, I have rethought this, and decided that I can probably write the
> functions I need using backtick calls to the mysql client. I did something
> rather rash and actually read man mysql, discovering that if I don't call it
> interactively, I don't have to try to parse the ASCII tables.
>
Yuck. Nothing is stopping you from going against the advice others
are giving, but there's no need to tell anyone that's what you're
doing. :-)
DBI is pretty nice and there are a lot of tutorials and documentation
available to make using it, pretty painless.
Re: Function notation with mysql
am 08.09.2007 01:26:30 von Keith Keller
On 2007-09-07, Lars Eighner wrote:
>
> Well, I have rethought this, and decided that I can probably write the
> functions I need using backtick calls to the mysql client.
That sounds really gruesome. The following pseudocode
@stuff=`mysql -e '$query'`;
foreach my $line (@stuff)
{
# process each returned line
}
is the moral equivalent of
$dbh=DBI::connect($dsn);
$sth=$dbh->prepare($query);
$sth->execute;
while ($row=$sth->fetch)
{
# process each row; $row is an arrayref
}
except you avoid the shell, you avoid a connection per query, you can do
nice stuff with prepare and execute so that you can iterate a query over
a list (and also let execute automatically quote arguments appropriately
before submitting the query), and @$row is already parsed. If your
script is basically a one-off, backticks are fine, but anything larger
and backticks will become masochistic in a hurry.
--keith
--
kkeller-usenet@wombat.san-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://www.therockgarden.ca/aolsfaq.txt
see X- headers for PGP signature information
Re: Function notation with mysql
am 08.09.2007 02:03:37 von Lars Eighner
In our last episode, <6a39r4x608.ln2@goaway.wombat.san-francisco.ca.us>, the
lovely and talented Keith Keller broadcast on comp.lang.perl.misc:
> On 2007-09-07, Lars Eighner wrote:
>>
>> Well, I have rethought this, and decided that I can probably write the
>> functions I need using backtick calls to the mysql client.
> That sounds really gruesome.
Perhaps, but I have been experimenting since I wrote the above, and I am
delighted. This makes so many things possible that I gave up on because I
couldn't fight my way through DBI. I rue the many hours I wasted at that.
> The following pseudocode
> @stuff=`mysql -e '$query'`;
> foreach my $line (@stuff)
> {
> # process each returned line
> }
> is the moral equivalent of
> $dbh=DBI::connect($dsn);
> $sth=$dbh->prepare($query);
> $sth->execute;
> while ($row=$sth->fetch)
> {
> # process each row; $row is an arrayref
> }
See what I mean? The direct version is simple, clean, easy to understand
and to edit. The objects are black boxes at the bottom of an opaque swamp:
there is no telling what they are doing or how.
> except you avoid the shell, you avoid a connection per query, you can do
> nice stuff with prepare and execute so that you can iterate a query over
> a list (and also let execute automatically quote arguments appropriately
> before submitting the query), and @$row is already parsed. If your
> script is basically a one-off, backticks are fine, but anything larger
> and backticks will become masochistic in a hurry.
Here's how I learned my lesson about objects:
I installed CGI::Kwiki. I thought it might be possible to customize it for a
project, although it was a horrible mess with javascript and all out of the
box. It said that it could be customized simply by writing replacement
modules and placing them in a local directory. Sounded good so far.
Well, the first thing I wanted to change was the DOCTYPE. I wanted to
change XHTML doctype to HTML. I grepped the distributed modules on XHTML,
locating all the doctype declarations in the distribution (all three
happened to be in template module). I rewrote the template module, put it
in the local lib and thought I was off to the races.
But no. Docs still came out as type XHTML. So I thought, well, maybe they
are rolling a doctype declaration out of parts. So I grepped on parts of
the XHTML doctype declaration, to see if I missed where the doctype really
was being generated. Nope. The doctype was not coming from anywhere in the
CGI::Kwiki distribution. Evidently it was coming from somewhere up the
dependencies. Where? After many hours I still do not know.
Somewhere, someone decided that I should want to use XHTML and that I was
not going to have a choice about it. And that is what OOP is all about:
preventing people from doing what they want to do.
When it become impossible to do anything in perl without objects, I'm
going back sed in Bourne scripts.
--
Lars Eighner
Countdown: 500 days to go.
What do you do when you're debranded?