0.0
No commit activity in last 3 years
No release in over 3 years
This library is meant to be compatible with the sqlanywhere gem. The only difference should be that sqlanywhere-ffi doesn't return magic numbers, but instead uses symbols. This library wraps the functionality provided by the SQL Anywhere DBCAPI library. This driver is intended to be a base-level library to be used by interface libraries such as Ruby-DBI and ActiveRecord. This driver can be used with SQL Anywhere 10 and later versions.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 1.3.1
 Project Readme

SQL Anywhere Ruby Driver

This is a native SQL Anywhere driver for Ruby. This library wraps the functionality provided by the SQL Anywhere DBCAPI library. This driver is intended to be a base-level library to be used by interface libraries such as Ruby-DBI and ActiveRecord.

This driver can be used with SQL Anywhere 10 and later versions.

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

The official code repository is located on GitHub. The repository can be cloned with:

git clone git://github.com/ccouzens/sqlanywhere-ffi.git

Running Unit Tests

  1. Change to the the test directory cd test
  2. Create a testing database: dbinit test
  3. Start the testing database: dbeng12 test.db
  4. Create the test schema: dbisql -c "eng=test;uid=dba;pwd=sql" test.sql
  5. Run the unit tests: ruby sqlanywhere_test.rb

If the tests fail to run, make sure you have set up the SQL Anywhere environment variables correctly. For more information, review the online documentation here. I run source /opt/sqlanywhere12/bin64/sa_config.sh in my shell before running the tests.

Sample

This script makes a connection, prints Successful Ruby Connection to the SQL Anywhere console, then disconnects.

# load the SQLAnywhere gem
require 'sqlanywhere-ffi'
# create an interface
api = SQLAnywhere::SQLAnywhereInterface.new()
# initialize the interface (doesn't actually do anything, but kept for compatibility)
SQLAnywhere::API.sqlany_initialize_interface( api )
# initialize our api object
api.sqlany_init()
# create a connection
conn = api.sqlany_new_connection()
# establish a connection
api.sqlany_connect(conn, "uid=dba;pwd=sql")
# execute a query without a result set
api.sqlany_execute_immediate(conn, "MESSAGE 'Successful Ruby Connection'")
# disconnect from the database
api.sqlany_disconnect(conn)
# free the connection resources
api.sqlany_free_connection(conn)
# free resources the api object uses
api.sqlany_fini()
# close the interface (doesn't actually do anything, but kept for compatibility)
SQLAnywhere::API.sqlany_finalize_interface( api )