Guest User

Untitled

a guest
Jul 21st, 2018
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. require 'data_objects'
  2. #this has to become the gem instead of the .rb I think
  3. require 'MonetDB.rb'
  4.  
  5. module DataObjects
  6. module MonetDB
  7. @monetdb
  8.  
  9. attr_reader :connected
  10.  
  11. class Connection < DataObjects::Connection
  12. def initialize(uri_s)
  13. uri = DataObjects::URI::parse(uri_s)
  14.  
  15. @monetdb = MonetDB::MonetDB.new
  16. username = uri.user
  17. password = uri.password
  18. host = uri.host
  19. port = uri.port
  20. db_name = uri.path
  21.  
  22. lang = query["lang"]
  23. auth_type = query["auth_type"]
  24.  
  25. @monetdb.connect(user, password, lang, host, port, db_name, auth_type)
  26. end
  27.  
  28. def dispose
  29. @monetdb.close
  30. @monetdb = nil
  31. end
  32.  
  33. def create_command(text)
  34. XQueryCommand.new(self, text) if @monetdb.lang == 'xquery'
  35. end
  36. end #class Connection
  37.  
  38. require 'xmlsimple'
  39. class XQueryCommand < DataObjects::Command
  40. def execute_non_query(query)
  41. @connection.query(query)
  42. end
  43.  
  44. def execute_reader(query)
  45. result = @connection.query(query)
  46. data = XmlSimple.xml_in(result.result)
  47. #turn xml into reader
  48. end
  49.  
  50. def set_types(column_types)
  51. raise NotImplementedError.new
  52. end
  53. end #class MonetDBCommand
  54.  
  55. class Reader < DataObjects::Reader
  56. def fields
  57. end
  58.  
  59. def values
  60. end
  61.  
  62. def close
  63. end
  64.  
  65. def next!
  66. end
  67.  
  68. def field_count
  69. end
  70. end #class Reader
  71. end #module MonetDB
  72.  
  73. #alias because of capitalisation convention
  74. module Monetdb
  75. include MonetDB
  76. end
  77. end #module DataObjects
Add Comment
Please, Sign In to add comment