Fog Creek Software
Discussion Board




Knowledge Base
Documentation
Terry's Tips
Darren's Tips

Perl and CityDesk

Has anyone successfully used Perl to manipulate a CityDesk file? I've written plenty of scripts and modules that interact with Berkeley DB and MySQL (via the modules DBI, DBD, DB_File, Storable, MLDBM, etc), but the deeper I delve into the mechanics of interfacing Perl with Access files, the more confused I get.

In fact, I'm not entirely sure it is possible for me to do anything with Perl and CD files, as I do not own Access or any other Microsoft database projects. But poking around online it sounds like (?) there might be a way, by downloading a driver or three, to bridge Access files to Jet to ODBC to Perl. Or something.

I'm going to stop typing as I now have a headache just from thinking about it.

Ryan Tate
Friday, April 02, 2004

I don't think you need to own Access; CityDesk comes with all the libraries you'd need to get to Jet.  You do need to have the MS Access ODBC driver but that's freely available and probably already installed on modern Windows systems...

I don't know much about programming against Access with Perl, but using the ODBC drivers with a suitable connection string like

Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\mycitydesksite.cty;Uid=Admin;Pwd=;

ought to work.

Here's someone who has Perl talking to Access databases:

http://hypernews.ngdc.noaa.gov/HyperNews/get/hmi/16.html?nogifs

Joel Spolsky
Fog Creek Software
Friday, April 02, 2004

Use the DBI::ADO package

Here is a sample perl script to list all article headlines.

use DBI;

$dbh = DBI->connect( "dbi:ADO:Provider=Microsoft.Jet.OLEDB.4.0;Data Source=work.cty;" );

$sth = $dbh->prepare( "SELECT ixSet,sHeadline FROM tblArticle" );

$sth->execute();

while( my ($id, $head) = $sth->fetchrow_array ) {
  print "$id) $head\n";
  }

$sth->finish();

$dbh->disconnect();

Brad
Saturday, April 03, 2004

THANKS for the help! I haven't tested anything yet but I appreciate the pointers and example code. I'll post again if I get anything interesting ginned up for myself.

Ryan Tate
Monday, April 05, 2004

*  Recent Topics

*  Fog Creek Home