Class: Outhad::Integrations::Source::Oracle::Client
- Inherits:
-
SourceConnector
- Object
- SourceConnector
- Outhad::Integrations::Source::Oracle::Client
- Defined in:
- lib/outhad/integrations/source/oracle_db/client.rb
Instance Method Summary collapse
- #check_connection(connection_config) ⇒ Object
- #discover(connection_config) ⇒ Object
- #read(sync_config) ⇒ Object
Instance Method Details
#check_connection(connection_config) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/outhad/integrations/source/oracle_db/client.rb', line 7 def check_connection(connection_config) connection_config = connection_config.with_indifferent_access create_connection(connection_config) ConnectionStatus.new( status: ConnectionStatusType["succeeded"] ). rescue StandardError => e ConnectionStatus.new( status: ConnectionStatusType["failed"], message: e. ). end |
#discover(connection_config) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/outhad/integrations/source/oracle_db/client.rb', line 19 def discover(connection_config) records = [] connection_config = connection_config.with_indifferent_access query = "SELECT table_name, column_name, data_type, nullable FROM all_tab_columns WHERE owner = '#{connection_config[:username].upcase}' ORDER BY table_name, column_id" conn = create_connection(connection_config) cursor = conn.exec(query) while (row = cursor.fetch) records << row end catalog = Catalog.new(streams: create_streams(records)) catalog. rescue StandardError => e handle_exception( "ORACLE:DISCOVER:EXCEPTION", "error", e ) end |
#read(sync_config) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/outhad/integrations/source/oracle_db/client.rb', line 41 def read(sync_config) connection_config = sync_config.source.connection_specification.with_indifferent_access query = sync_config.model.query db = create_connection(connection_config) query(db, query) rescue StandardError => e handle_exception(e, { context: "ORACLE:READ:EXCEPTION", type: "error", sync_id: sync_config.sync_id, sync_run_id: sync_config.sync_run_id }) end |