Sample database setup to test the [transfer-db](https://hub.darcs.net/mihaigiurgeanu/transfer-db) project.

root

transfer-sample-db

Sample database setup to test the transfer-db project.

The setup consist in:

  • A source sqlite database containing sample data to be copied in a destination database.
  • A destination sqlite database containing only the tables that will be populated with data from the source database.
  • ODBC setup for source and desintation databases

sqlite setup

Install sqlite3 on your system. The steps of installing sqlite are not covered by this README.

source database setup

The source database is a sqlite database file. You can store it in a location and a name you choose. You must have write access to the database file. In the following example we suppose the database file will be stored in a file named source.db in the $HOME/workspace/source.db.

$ sqlite3 ~/workspace/source.db
SQLite version 3.8.2 2013-12-06 14:53:30
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> .read source.sql
sqlite>

destination database setup

The destination database is a sqlite database file. You can store it in a location and a name you choose. You must have write access to the database file. In the following example we suppose the database file will be stored in a file named destination.db in the $HOME/workspace/destination.db

$ sqlite3 ~/workspace/destination.db
SQLite version 3.8.2 2013-12-06 14:53:30
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> .read destination.sql
sqlite>

odbc setup

You need to have installed ODBC on your system. For non Windows systems, you meay use unixODBC. Use the system packager to install it, if available. For macs, you can use brew.

Havning ODBC installed on your system, declare the source and destination databases to the ODBC.

To do this, you need to install sqlite3 ODBC driver. On a Mac OSX you can also use brew to install sqlite odbc driver.

If you are using unixODBC, you need to add the installed driver to the unixODBC list of drivers. Use odbcinst utility for this:

$ odbcinst -i -d -f odbcinst.ini

You may need to adjust the odbcinst.ini file before running the command. Check the driver installation with:

$ odbcinst -q -d -n SQLite3
[SQLite3]
Description=SQLite3 driver
Driver=/usr/local/lib/libsqlite3odbc.so
Setup=/usr/local/lib/libsqlite3odbc.so
FileUsage=1
UsageCount=1

After installing the driver, you should create the datasource entries for the source and destination databases. For unixodbc, you will edit and adjust the provided templates (src-odbc.ini and dst-odbc.ini) and then run the odbcinst utility, like this:

$ odbcinst -i -s -h -f src-odbc.ini
$ odbcinst -i -s -h -f dst-odbc.ini 

Again, make sure you have the right paths for the source and destination database files in the src-odbc.ini and dst-odbc.ini files.