How to connect to MiaRec Database
MiaRec Business uses PostgreSQL as database engine.
This article describes how to connect to PostgreSQL database via ODBC driver.
This database has API for many programing languages, like C, Java, C# etc.
Check following web-page: http://pgfoundry.org/softwaremap/trove_list.php?form_cat=310
One of methods of accessing database is using ODBC driver.
First of all, download ODBC driver and install in the same computer, where your .NET application is running.
http://www.postgresql.org/ftp/odbc/versions/msi/
Here you will find a sample source code on C# for accessing PostgreSQL database:
http://psqlodbc.projects.postgresql.org/howto-csharp.html
Please, note, MiaRec database (PostgreSQL) is listening on port 6082 (by default, but this may be changed during installation of MiaRec).
Database name: miarec
Database user: miarec
Password: password
If you are running your application on different computer than MiaRec is running on, then you need to do additional changes inside MiaRec configuration.
By default, only local applications can access MiaRec Database. Access to database via network is forbidden.
In order to access MiaRec Database (PostgreSQL) from another computer (non-localhost), you need to make two things:
- Edit file pg_hba.conf (located in C:\Program Files\MiaRec Business\Data\DB)
- Edit file postgresql.conf
In the first file you need to add ip-address of another computer, from where you do access of database.
For example:
host all all 192.168.0.5/32 trust
Of course, you can allow access to whole your network, like:
host all all 192.168.0.0/24 trust
In the second file you need to find following string:
#listen_addresses = 'localhost' # what IP address(es) to listen on;
By default it is commented (see hash symbol #).
You need to uncomment it and change ‘localhost’ to ‘*’, like:
listen_addresses = '*' # what IP address(es) to listen on;
Save the file and restart “MiaRec DB” service.
After that you will be able to access database from another computers.
Now you need to configure ODBC Data Source on your computer.
Open "ODBC Data Source Administrator" in Control Panel->Administration.
Note for Vista 64-bit systems:
If you are running Vista 64-bit, then you need to start "ODBC Data Source Administrator" manually from here: C:\Windows\SysWOW64\odbcad32.exe
PostgreSQL itself is 32-bit and ODBC driver is also 32-bit. So, you need to open 32-bit version of "ODBC Administrator".
Inside "ODBC Data Source Administrator" select tab "User DSN" and click on button "Add.." (see below screenshot).

Find in the list "PostgreSQL Unicode", select it and click on "Finish" button (see below screenshot).

You will see new dialog, where you will need to enter settings of your ODBC connection (see below screenshot).
"Data Source" is a name of this connection. You can type here any value, for example, "MiaRecDatabase".
"Database" should have value "miarec" (without quotes).
"Server" is ip-address of the server, where MiaRec is running, for example, 192.168.0.10 or "localhost", if you start Excel and MiaRec on the same machine.
"User Name" is "miarec" (without quotes).
"Port" is 6082 (this is a default port. It may be changed during installation of MiaRec).
"Password" is "password" (without quotes).
You can click on "Test" button to check, if connection of database is working.
Then click on "Save" button.

Now you can use this ODBC connection for accessing MiaRec Database from your application.
For example, you can import call history into Excel for complex analyzing.
Read following article: http://www.miarec.com/knowledge/kb147
There are a few tables inside MiaRec Database.
But for you only one table is a point of interest.
It is ‘calls’ table.
In this table MiaRec stores information about every recorded call.
Audio file itself is stored on disk.
The database contains only a path to that file (for example, C:\Program Files\MiaRec Business\Data\Recordings\20090127\20090127100507.wav).
Please, note, MiaRec stores initially audio in WAV uncompressed format (*.wav).
A separate application does automatic converting of WAV to MP3 format every hour.
So, every *.wav file is replaced with *.mp3.
File path changes from:
C:\Program Files\MiaRec Business\Data\Recordings\20090127\20090127100507.wav
To:
C:\Program Files\MiaRec Business\Data\Recordings\20090127\20090127100507.mp3
Please, note, at the moment MiaRec doesn’t update paths inside database after converting of files.
So, if you are accessing files from your application, then you would need to use following algorithm:
- First try to access file with *.wav extension (the same as path inside database)
- If failed, then try to access the same file, but with *.mp3 extension.