PDA

View Full Version : Writing a New DB Interface



JSonnabend
2005-06-07, 06:29
I hope I'm posting this in the right spot. If not, my apologies.

I am currently using a great shareware cd and music file cataloging program called CATraxx. The DB backend for this program is MS Access. I'd love to be able to write a module that allows SlimServer to read the data from this database instead of using the standard SQL databases.

Can anyone point me in the right direction to get started? In what module does SlimServer read from the DB? How about write to the DB (which I would want to kill)?

TIA

- Jeff

kdf
2005-06-07, 06:42
I had looked for a way to interface with MS Access formats a while ago as an
option for musicmagic integration. There are CPAN modules that can interract
with an ODBC server running ms access, but for windows only. I can't recall
the exact module names, but searching CPAN.org is a good plan to start.
Unfortunately, I never found anything that can directly work with the db file.
MS just doesn't make it easy to create something third party to work with their
formats.

-kdf

John A. Tamplin
2005-06-07, 06:50
On Tue, 7 Jun 2005, JSonnabend wrote:

> Can anyone point me in the right direction to get started? In what
> module does SlimServer read from the DB? How about write to the DB
> (which I would want to kill)?

You are going to have issues trying to match the schema between what
CATraxx uses and what Slim wants, plus there may be portability issues
using the ADO/ODBC driver. To help get you started, you will need a DBI
connect string something like this:

$db=DBI->connect('dbi:ADO:Provider=Microsoft.Jet.OLEDB.4.0; Jet OLEDB:Engine Type=5;Data Source=path_to_db.mdb','admin',{RaiseError=>1,AutoCommit=>1});

Without views and other abilities from a real SQL engine, you are likely
to find it impractical to match the schemas. You may have better results
writing a utility to transfer data back and forth as necessary.

You can also use dbi:ODBC:odbc_data_source and configure an ODBC data
source using odbcad32.exe.

--
John A. Tamplin jat (AT) jaet (DOT) org
770/436-5387 HOME 4116 Manson Ave
Smyrna, GA 30082-3723

kdf
2005-06-07, 06:58
Quoting "John A. Tamplin" <jat (AT) jaet (DOT) org>:

> $db=DBI->connect('dbi:ADO:Provider=Microsoft.Jet.OLEDB.4.0; Jet OLEDB:Engine
> Type=5;Data Source=path_to_db.mdb','admin',{RaiseError=>1,AutoCommit=>1});

If you take a look at the MusicMagic plugin (Plugins/MusicMagic/Plugin.pm), you
could make a similar plugin that parses the common information and feeds it to
slimserver in much the same way. Look specifically at exportFunction() for
getting the data formatted in a way acceptable to slimserver.

-kdf

JSonnabend
2005-06-07, 07:03
Thanks for the feedback, guys.

I've programmed fairly extensively in Delphi, including plenty of MS Access Jet stuff, so that end of things I'm not too concerned about (although I'll need to figure out the PERL interface for that).

My initial thought was to do exactly as suggested, namely, write some Delphi code to copy the data from Access into the SlimServer SQL db, mapping fields as appropriate.

Instead, though, I was hoping to access the Access data directly by handling SlimServer's calls to the DB and returning the appropriate information. Could you point me to where the DB reads are performed? Generally, what do they look like?

- Jeff

JSonnabend
2005-06-07, 07:11
If you take a look at the MusicMagic plugin (Plugins/MusicMagic/Plugin.pm), you could make a similar plugin that parses the common information and feeds it to slimserver in much the same way. Look specifically at exportFunction() for getting the data formatted in a way acceptable to slimserver.
Thanks, I'll take a look.

- Jeff