Created
July 24, 2014 03:18
-
-
Save lukeholder/35767b5750f3ea4c3b3d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sequel' | |
connection_string = 'driver={Timberline Data};dbq=\\\\doric-server19\\Timberline Office\\Gold\\DORIC GROUP\\;codepage=1252;dictionarymode=0;standardmode=1;maxcolsupport=1536;shortenames=0;databasetype=1;uid=l;pwd=Doricsep14;' | |
DB = Sequel.odbc(:driver=>'Timberline Data',:drvconnect=>connection_string) | |
DB.extend_datasets do | |
Sequel::Dataset.def_sql_method(self, :select, %w'select distinct limit columns into from join where group order having compounds') | |
def select_limit_sql(sql) | |
if l = @opts[:limit] | |
sql << 'TOP ' | |
literal_append(sql, l) | |
end | |
end | |
end | |
JCM_MASTER__COST_CODE = Sequel.identifier(:JCM_MASTER__COST_CODE) | |
JCM_MASTER__JOB = Sequel.identifier(:JCM_MASTER__JOB) | |
GLM_MASTER__ACCOUNT = Sequel.identifier(:GLM_MASTER__ACCOUNT) | |
class Accounts < Sequel::Model | |
self.set_dataset(DB[GLM_MASTER__ACCOUNT]) | |
end | |
class CostCodes < Sequel::Model | |
self.set_dataset(DB[JCM_MASTER__COST_CODE]) | |
many_to_one :jobs, :key=>:job | |
end | |
class Jobs < Sequel::Model | |
self.set_dataset(DB[JCM_MASTER__JOB]) | |
one_to_many :cost_codes, :key=>:job | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment