NSSQL allows you to query directly against NetSuite through an ODBC connection. Define your tables, primary keys and columns and query away!
Add this line to your application's Gemfile:
gem 'nssql'And then execute:
$ bundle
Or install it yourself as:
$ gem install nssql
Follow the steps below to start using NSSQL.
NSSQL::Settings.configure do |config|
config.odbc_user = 'ODBC_USER'
config.odbc_client_id = 'ODBC_CLIENT_ID'
config.odbc_certificate_id = 'ODBC_CERTIFICATE_ID'
config.odbc_private_key = 'ODBC_PRIVATE_KEY'
config.odbc_account = 'ODBC_ACCOUNT'
endor set ENV['ODBC_USER'], ENV['ODBC_CLIENT_ID'],
ENV['ODBC_CERTIFICATE_ID'], ENV['ODBC_PRIVATE_KEY'] and
ENV['ODBC_ACCOUNT']
class TestTable
include NSSQL::Table
ns_table_name :test_table
ns_primary_keys :id, :line_id
ns_column :id
ns_column :line_id
ns_column :name, as: :display_name
end
TestTable.ns_column_names # => [:id, :line_id, :name]
TestTable.ns_aliased_column_names # => [:id, :line_id, :display_name]TestTable.select_ns_columns_query will generate:
SELECT
id,line_id,name
FROM
test_table
ORDER BY
idWe can pass options, like TestTable.select_ns_columns_query(where: 'id > 500') and this will generate:
SELECT
id,line_id,name
FROM
test_table
WHERE id > 500
ORDER BY
idSelect to file
NSSQL.select_to_file('SELECT 1+1')Select array
NSSQL.select_array('SELECT 1+1')After checking out the repo, run bin/setup to install dependencies. Then, run rake test to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.
Bug reports and pull requests are welcome on GitHub at https://github.com/apoex/nssql. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
The gem is available as open source under the terms of the MIT License.
Everyone interacting in the Nssql project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.