Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Re^2: Accessing Access in Perl

by rpike (Scribe)
on Sep 23, 2010 at 13:59 UTC ( #861539=note: print w/replies, xml ) Need Help??

in reply to Re: Accessing Access in Perl
in thread Accessing Access in Perl

Do you have a simple example? I'm trying a few approaches and none seem to work (the directory for the mdb specified below may differ from what I originally posted). For example,
DBI->connect( "dbi:ODBC:driver=Microsoft Access Driver(*.mdb);dbq=C:/D +ownload/tmp/examples.MDB",'','') or die "Cannot open the file";
I get the error : DBI connect('driver=Microsoft Access Driver(*.mdb);dbq=C:/Download/tmp/examples.MDB','',...) failed: MicrosoftODBC Driver Manager Data source name no t found and no default driver specified (SQL-IM002) at line 7 Cannot open the file at line 7.

Replies are listed 'Best First'.
Re^3: Accessing Access in Perl
by Corion (Pope) on Sep 23, 2010 at 14:03 UTC

    I use the following:

    $dsn ||= "dbi:ODBC:driver=Microsoft Access Driver (*.mdb);dbq=$dbfile" +;

    Note that I have different whitespace. I assume that whitespace is significant.

    $dbfile is a filename with backslashes, which should not be significant, but you might want to try both.

      I must have left something out cause although I thought that is what I had in there it didn't work. I copied your post and it appears to work. Do you have a very simple, generic piece a code that selects everything from the database and prints it to the screen? I'm uncertain of the format and what data is in this database so I need to loop through and print some of the content to screen. One great approach would be to see the structure of the database. I haven't worked on Access/SQL in such a long time so I apologize for some of these noob-like questions. Thanks so much for the help.

        Have you tried opening the file in Access? I find Access a much more convenient application. Alternatively see Querylet.

        Maybe you are looking for a generic SQL statement to list things?

        select * from $tablename

        will give you the contents of a table.

Re^3: Accessing Access in Perl
by mje (Curate) on Sep 23, 2010 at 14:12 UTC

    I think you need to put {} around some key values in your connection string - they quote the value. Also you slashes are the wrong way around in the filespec.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://861539]
[Corion]: Meh. I have a very simple mechanism to scrape+track prices, and even to send me mail if something changes (via cron), but SQLite doesn't support window functions, so my simple SQL to determine a price change won't work :-( Maybe I should store the DB ...
[Corion]: ... in Pg, but that would mean that I'd have to deal with credentials and stuff :)
[Corion]: In fact, the whole thing is just four simple programs, one App::scrape, another being DBIx::RunSQL, and one some glue to convert a JSON object into an SQL INSERT statement (+DBI connect/execute), so it would be an incredibly simple solution...
[Corion]: ... but that simplicity falls down due to SQLite letting me down and me being too lazy to move to a real DB. Maybe DBD::CSV can handle window functions...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (10)
As of 2018-02-23 15:02 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (302 votes). Check out past polls.