SQL Anywhere ActiveRecord Driver

This is a SQL Anywhere driver for Ruby ActiveRecord. This driver requires the native SQL Anywhere Ruby driver. To get the native driver, use:

gem install sqlanywhere

This driver is designed for use with ActiveRecord 3.0.3 and greater.

This driver is licensed under the Apache License, Version 2.

Making a Connection

The following code is a sample database configuration object.

ActiveRecord::Base.configurations = {
  'arunit' => {
    :adapter  => 'sqlanywhere', 
    :database => 'arunit',       #equivalent to the "DatabaseName" parameter
    :server   => 'arunit',       #equivalent to the "ServerName" parameter
    :username => 'dba',          #equivalent to the "UserID" parameter
    :password => 'sql',          #equivalent to the "Password" parameter
    :encoding => 'Windows-1252', #equivalent to the "CharSet" parameter
    :commlinks => 'TCPIP()',     #equivalent to the "Commlinks" parameter
    :connection_name => 'Rails'  #equivalent to the "ConnectionName" parameter
}

Running the ActiveRecord Unit Test Suite

  1. Open <ACTIVERECORD_INSTALL_DIR>/rakefile and modify the line:

    for adapter in %w( mysql postgresql sqlite sqlite3 firebird db2 oracle sybase openbase frontbase )
    

    to include sqlanywhere. It should now look like:

    for adapter in %w( mysql postgresql sqlite sqlite3 firebird db2 oracle sybase openbase frontbase sqlanywhere )
    
  2. Create directory to hold the connection definition:

    mkdir <ACTIVERECORD_INSTALL_DIR>/test/connections/native_sqlanywhere
    
  3. Copy test/connection.rb into the newly created directory.

  4. Create the two test databases. These can be created in any directory.

    dbinit -c arunit
    dbinit -c arunit2
    dbsrv11 arunit arunit2
    

    If the commands cannot be found, make sure you have set up the SQL Anywhere environment variables correctly. For more information review the online documentation here.

  5. Run the unit test suite from the ActiveRecord install directory:

    rake test_sqlanywhere
    

    If the migration tests fail, make sure you have set up the SQL Anywhere environment variables correctly. For more information review the online documentation here.