Pharo 1.3 ODBC working on Windows 7

Wow. Eight months since my last post.  It is now apparent the impact over that time of my 60-70 hour work week onsite at a mine expansion.

This post summarises the result of discussion on the pharo-project mailling list where I sought assistance getting ODBC working on Pharo 1.3.  Credit goes to Mariano Peck and Eliot Mirranda for assistance troubleshooting, providing a slightly older configuration that worked, and then the latest VM build.  I am happy to report that ODBC appears to be working with the Pharo 1.3 image on MS Windows 7 using CogVM version 2522.

The purpose of this is that I have a UML design an application has stored in a Microsoft Access database.  I want to use Pharo to implement that design directly into Smalltalk classes since I could not find a common export/import format.  ConfigurationOfODBC looked promising so I followed instructions at http://www.pharocasts.com/2010/12/access-database-through-odbc.html, except that rather than using SQLLite I started with a blank Microsoft Access database.  This worked well on Pharo 1.2.1 but not out of the box Pharo 1.3.

Here is the method to get ODBC working and tested with Pharo 1.3.

1. With this  TestMDB.mdb in a local folder, set up the ODBC data source using
Start > Control Panel > Administrative Tools > Data Sources (ODBC)

ODBC Data Source Administrator

Clicked <Add…> and choose the Microsoft Access Driver

and <Select…> the TestMDB.mdb file configured as Data Source Name “TestMDB”

ODBC Microsoft Access Setup

ODBC Microsoft Access Setup

which gives…

2. Unzip Pharo-1.3-13315-OneClick.zip and then delete all files from
folder “Pharo-1.3-13315-OneClick.app”, leaving just the Contents folder.

3. Extract the files from VM.r2522/cogwin.zip into folder “Pharo-1.3-13315-OneClick.app”

4. Copy the “ImageFile=Contents\Resources\pharo.image” line from the old pharo.ini into Croquet.ini and then run Croquet.exe.

5. Load the ODBC package from within Pharo.  I had some trouble accessing Squeaksource, but I found success using a mirror (you might skip the first two lines…)

Gofer new url: ‘http://dsal.cl/squeaksource/MonticelloRedirect’; package: ‘MontiRedirect’; load.

MRManager redirectFrom: ‘http://www.squeaksource.com/’ to: ‘http://dsal.cl/squeaksource/’.

Gofer new
squeaksource: ‘ODBC’;
package: ‘ConfigurationOfODBC’; load.
(Smalltalk at: #ConfigurationOfODBC) load.

6. And then finally, the successful test of ODBC…

connection := ODBCConnection dsn: ‘TestMDB’ user: ” password: ”.
table := (connection query: ‘select * from user;’) execute asTable.
connection close.
table inspect.

Inspector on ODBCResultTable

Inspector on ODBCResultTable

Thats all.  Now time to explore that UML design….

Here are some links to the full discussion and a backup cache of the files

Update 24 Dec 2011…

7. Just recording an example for the next part of actually processing the database. Following on from the previous step…

( row := table first ) inspect.
( name := row at: #name ) inspect.
( age := row at: #age ) inspect.
( allNames := table collect: [:each | each at: #name] ) inspect.

To go with the above example I have also uploaded a new file TestMDB – 2011-12-24.zip with a few additional rows of data.

This entry was posted in Uncategorized and tagged , , , . Bookmark the permalink.

3 Responses to Pharo 1.3 ODBC working on Windows 7

  1. Pingback: Windows 7 Pharo DBXTalk – “my hack” | openInWorld

  2. Bart Veenstra says:

    A small but very important addition to the above post.

    For 64-bit Windows 7 installations, the above method will not work with the default 64-bit ODBC driver from mySQL. You need to install the 32-bit version for CogVM to work with it correctly.

    But Microsoft decided to bring in a huge mind f*ck (excerpt from http://support.microsoft.com/kb/942976):

    The 32-bit version of the Odbcad32.exe file is located in the %systemdrive%\Windows\SysWoW64 folder.
    The 64-bit version of the Odbcad32.exe file is located in the %systemdrive%\Windows\System32 folder.

    So, you’ll need the 32-bit version of the ODBC manager to add the DSN. Make sure you add the _32 and _64 to your DSN names.

    If you try to use the 64 bit version you will end up with the following error:
    Error: [Microsoft][ODBC Driver Manager] The specified DSN contains an architecture mismatch between the Driver and Application

    HTH

    Like or Dislike: Thumb up 1 Thumb down 0

Leave a Reply