Simple, synchronous interaction with a local server process

Simple, synchronous interaction with a local server process

am 23.06.2010 22:31:29 von Chap Harrison

Hi,

I have a Perl app that makes SQL queries to DBF (DBase IV) databases. I =
haven't found a reliable DBI::DBD module for accessing DBase IV, but I =
do have a copy of the JDBC library, so I wrote a simple Java =
command-line program that accepts a database path and a query on the =
command line, connects to the database, executes the query, and writes =
the result set to STDOUT. Then, from Perl, I write

my @rows =3D qx(java lmi_DBFAccess -d '$db_path' -q "$sql_query");
=20
It's kludgy, but it works. However, due to the overhead of qx, and of =
establishing a fresh connection to the database for every query, it's =
slow, and I want to improve it.

I figure that I should convert lmi_DBFAccess to run as a local daemon, =
and use IPC to send the above parameters - and receive the results. =
lmi_DBFAccess will now cache its previously-established connections and =
use them when needed.

I've never done IPC before (well, besides command piping). I've been =
wading through perlipc, and I have a headache. Would someone be so kind =
as to give a high-level outline of what I need to do on the Perl side?

Some salient details:

-- I'm running in Cygwin on Windows Server 2003
-- Perl 5.10
-- As can be inferred from the qx above, a synchronous protocol is fine.

Sure do appreciate it!
Chap Harrison=

--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/

Re: Simple, synchronous interaction with a local server process

am 24.06.2010 04:24:26 von chas.owens

On Wed, Jun 23, 2010 at 16:31, Chap Harrison wrote:
> Hi,
>
> I have a Perl app that makes SQL queries to DBF (DBase IV) databases. =C2=
=A0I haven't found a reliable DBI::DBD module for accessing DBase IV, but I=
do have a copy of the JDBC library, so I wrote a simple Java command-line =
program that accepts a database path and a query on the command line, conne=
cts to the database, executes the query, and writes the result set to STDOU=
T.  Then, from Perl, I write
>
>    my @rows =3D qx(java lmi_DBFAccess -d '$db_path' -q "$sql_qu=
ery");
>
> It's kludgy, but it works.  However, due to the overhead of qx, and =
of establishing a fresh connection to the database for every query, it's sl=
ow, and I want to improve it.
>
> I figure that I should convert lmi_DBFAccess to run as a local daemon, an=
d use IPC to send the above parameters - and receive the results.  lmi=
_DBFAccess will now cache its previously-established connections and use th=
em when needed.
>
> I've never done IPC before (well, besides command piping).  I've bee=
n wading through perlipc, and I have a headache.  Would someone be so =
kind as to give a high-level outline of what I need to do on the Perl side?
>
> Some salient details:
>
> -- I'm running in Cygwin on Windows Server 2003
> -- Perl 5.10
> -- As can be inferred from the qx above, a synchronous protocol is fine.
>
> Sure do appreciate it!
> Chap Harrison
snip

You may want to look at [Inline::Java][1]. It allows you interact
with Java from inside of Perl instead of having to run a separate
process.

[1] : http://search.cpan.org/dist/Inline-Java/Java.pod

--=20
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/

Re: Simple, synchronous interaction with a local server process

am 24.06.2010 09:16:15 von Shlomi Fish

On Wednesday 23 Jun 2010 23:31:29 Chap Harrison wrote:
> Hi,
>
> I have a Perl app that makes SQL queries to DBF (DBase IV) databases. I
> haven't found a reliable DBI::DBD module for accessing DBase IV, but I do
> have a copy of the JDBC library, so I wrote a simple Java command-line
> program that accepts a database path and a query on the command line,
> connects to the database, executes the query, and writes the result set to
> STDOUT. Then, from Perl, I write
>
> my @rows = qx(java lmi_DBFAccess -d '$db_path' -q "$sql_query");
>
> It's kludgy, but it works. However, due to the overhead of qx, and of
> establishing a fresh connection to the database for every query, it's
> slow, and I want to improve it.
>
> I figure that I should convert lmi_DBFAccess to run as a local daemon, and
> use IPC to send the above parameters - and receive the results.
> lmi_DBFAccess will now cache its previously-established connections and
> use them when needed.
>
> I've never done IPC before (well, besides command piping). I've been
> wading through perlipc, and I have a headache. Would someone be so kind
> as to give a high-level outline of what I need to do on the Perl side?
>

Look at IO::Socket ( http://search.cpan.org/perldoc?IO::Socket::INET ) and
maybe IO::All ( http://search.cpan.org/dist/IO-All/ ). You initialise a
socket, connect() to a remote port, and then you can use print , read (or
<...> in Perl's case) and when you're done - close().

Regards,

Shlomi Fish

> Some salient details:
>
> -- I'm running in Cygwin on Windows Server 2003
> -- Perl 5.10
> -- As can be inferred from the qx above, a synchronous protocol is fine.
>
> Sure do appreciate it!
> Chap Harrison

--
------------------------------------------------------------ -----
Shlomi Fish http://www.shlomifish.org/
What Makes Software Apps High Quality - http://shlom.in/sw-quality

God considered inflicting XSLT as the tenth plague of Egypt, but then
decided against it because he thought it would be too evil.

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/

Re: Simple, synchronous interaction with a local server process

am 26.06.2010 14:34:17 von Jenda Krynicky

From: Chap Harrison
> I have a Perl app that makes SQL queries to DBF (DBase IV) databases.
> I haven't found a reliable DBI::DBD module for accessing DBase IV, but
> I do have a copy of the JDBC library, so I wrote a simple Java
> command-line program that accepts a database path and a query on the
> command line, connects to the database, executes the query, and writes
> the result set to STDOUT. ...

Did you try DBD::ODBC? I do believe there are still ODBC drivers for
dBaseIV installed on your computer so this should work. What problems
did not you have?

Jenda
===== Jenda@Krynicky.cz === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery


--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/

Re: Simple, synchronous interaction with a local server process

am 27.06.2010 07:47:20 von Chap Harrison

On Jun 26, 2010, at 7:34 AM, Jenda Krynicky wrote:

> Did you try DBD::ODBC? I do believe there are still ODBC drivers for=20=

> dBaseIV installed on your computer so this should work. What problems=20=

> did not you have?=20

I *think* the problem is that dBaseIV drivers cost money. The company =
that I work for does have a license for the JDBC module, which is why =
I'm using that.

I can't recall the problems I had a year or so ago, looking for an =
open-source (or at least free-as-in-beer) solution - seems to me I found =
some Version < 1.0 drivers that didn't really install. Or something.

You're right, DBD::ODBC would be by far the simplest approach, so I may =
see whether our license for JDBC also happens to include an ODBC module.=

--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/

Re: Simple, synchronous interaction with a local server process

am 27.06.2010 13:29:13 von Jenda Krynicky

From: Chap Harrison
> On Jun 26, 2010, at 7:34 AM, Jenda Krynicky wrote:
>
> > Did you try DBD::ODBC? I do believe there are still ODBC drivers for
> > dBaseIV installed on your computer so this should work. What problems
> > did not you have?
>
> I *think* the problem is that dBaseIV drivers cost money. The company
> that I work for does have a license for the JDBC module, which is why
> I'm using that.
>
> I can't recall the problems I had a year or so ago, looking for an
> open-source (or at least free-as-in-beer) solution - seems to me I
> found some Version < 1.0 drivers that didn't really install. Or
> something.
>
> You're right, DBD::ODBC would be by far the simplest approach, so I
> may see whether our license for JDBC also happens to include an ODBC
> module.

dBaseIV drivers should install with ODBC on Windows. Within MDAC or
whatever they call it.
http://www.microsoft.com/downloads/details.aspx?displaylang= en&FamilyI
D=6c050fe3-c795-4b7d-b037-185d0506396c

Getting some drivers that work under Unix would be a problem, but
Windows should be fine.

If you start the ODBC Manager (odbcad32.exe) do you see the Microsoft
Access dBASE Driver? That's the one you need. It can handle dBase
III, IV and 5.0.

Jenda
===== Jenda@Krynicky.cz === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery


--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/