Connecting to Databases

The process of connecting to a database involves two major steps:

  1. Setup the appropriate database drivers on the server. Iguana supports three database APIs to connect to various databases: Open Database Connectivity (ODBC), MySQL API, and Oracle OCI.

  2. Use a connection object to connect to the database. We strongly recommend using the db.connect function to create the connection object so that you can use the methods on the connection object. Methods exist to create local database tables, merge them with external databases, and perform queries on external databases.

Select the drop downs below for how to setup the required database drivers and connect IguanaX:

Connect to MS SQL Server with ODBC:

  1. Set up the ODBC data source:

  2. Use a component to connect to the database:

function main() local conn = db.connect{ api=db.SQL_SERVER, name='<your_odbc_server_name>', -- ODBC DSN user='', -- use empty string for integrated security password='', -- use empty string for integrated security use_unicode = true, live = true } conn:execute{sql='SELECT * FROM <your table>', live=true} end

Iguana can connect with MySQL in two methods:

Connect to MySQL with ODBC:

  1. Set up the ODBC data source:

  2. Use a component to connect to the database:

function main() local conn = db.connect{ api=db.MY_SQL_ODBC, name='<your_odbc_server_name>', -- ODBC DSN user='<your_login>', password='<secret>', use_unicode = true, live = true } conn:execute{sql='SELECT * FROM <your table>', live=true} end

 

Connect to MySQL with libmysql:

  1. Install the libmysql shared library:

  2. Use a component to connect to the database:

function main() local conn = db.connect{ api=db.MY_SQL, name='<mydatabase@server_name>', user='<your_login>', password='<secret>', use_unicode = true, live = true } conn:execute{sql='SELECT * FROM <your table>', live=true} end
  • The name of the host can be specified as any of the following:

    • The machine name: mydatabase@server_name

    • The server name: mydatabase@server_name

    • The IP address: mydatabase@10.10.10.10

    • Port: If the MySQL server is not using the default port 3306, it can be specified in the name parameter: mydatabase@server_name:1111

Connect to PostgreSQL with ODBC:

  1. Set up the ODBC data source:

  2. Use a component to connect to the database:

Connect to Oracle with OCI (TNS Alias):

  1. Set up the Oracle OCI drivers and create a TNS Alias:

  2. Use a component to connect to the database:

 

Connect to Oracle with Easy Connect (EZConnect):

  1. Set up the Oracle OCI drivers and EZConnect String:

  2. Use a component to connect to the database:

 

Connect with Oracle with ODBC:

  1. Set up the Oracle OCI and ODBC drivers:

  2. Use a component to connect to the database:

Connect to Snowflake with ODBC:

  1. Set up the ODBC data source:

  2. Use a component to connect to the database: