Skip to content

Latest commit

 

History

History
113 lines (76 loc) · 3.02 KB

README.md

File metadata and controls

113 lines (76 loc) · 3.02 KB

NSSQL

Gem Version Build Status Maintainability Test Coverage

NSSQL allows you to query directly against NetSuite through an ODBC connection. Define your tables, primary keys and columns and query away!

Installation

Add this line to your application's Gemfile:

gem 'nssql'

And then execute:

$ bundle

Or install it yourself as:

$ gem install nssql

Usage

Follow the steps below to start using NSSQL.

Settings

NSSQL::Settings.configure do |config|
  config.user     = 'USER'
  config.password = 'PASSWORD'
end

or set ENV['NETSUITE_USER'] and ENV['NETSUITE_PASSWORD']

Table

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]

Select columns

TestTable.select_ns_columns_query will generate:

SELECT
  id,line_id,name
FROM
  test_table
ORDER BY
  id

We 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
  id

Other selects

Select to file

NSSQL.select_to_file('SELECT 1+1')

Select array

NSSQL.select_array('SELECT 1+1')

Development

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.

Contributing

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.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the Nssql project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.