monetdb 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/CHANGELOG.rdoc +4 -0
- data/LICENSE +3 -1
- data/README.rdoc +14 -141
- data/VERSION +1 -1
- data/lib/monetdb/data.rb +3 -3
- data/lib/monetdb/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MWJkMDFjNjQyYWY5ZTFiY2IyZmU5YTQwYTUwMjhiZjY0OWRkYTM3Mg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZTBlNWNjNDA1YTAzN2I2YzYyZGZmZmVkYjEyYWVhMDk3MmI3OWE5OA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZWNiM2RmYmM1MTQ0MjE3ZDk4NzVjYWI5ZDYzMDFjMDFmYTg0YmNhZGYwYzIx
|
10
|
+
ZmE3MDJiNThmZGFhNjM5ZDQxODEwMjU3ZDVkNmM4MTFiZjg1YjE1NzU1NzNh
|
11
|
+
MjkzZGRkYTI0NjdhMjcwN2RlZGVhODk0NWIzZGMyMjkyMzZjNTI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ODUzYzExNWY5N2VjOWI0OWFiMmJjNDgzMDIyMDBjMmRlYTU4ZjU2NWM0ZTMy
|
14
|
+
NjM2MDMwODkzNzMzNTZkM2I2ZGU0YjhjMGU4ZTNkMGViNzU3MWY4YmNhYjhj
|
15
|
+
ZGEyZTMxY2Y4NzgyYWU2ZWZlMzgwZjcxNWU0ZmJhMGZjZTcxZjk=
|
data/CHANGELOG.rdoc
CHANGED
data/LICENSE
CHANGED
@@ -14,4 +14,6 @@ The Initial Developer of the Original Code is CWI.
|
|
14
14
|
Portions created by CWI are Copyright (C) 1997-July 2008 CWI.
|
15
15
|
|
16
16
|
Copyright August 2008-2011 MonetDB B.V.
|
17
|
-
All Rights Reserved.
|
17
|
+
All Rights Reserved.
|
18
|
+
|
19
|
+
Copyright (c) 2014 Paul Engel, released under the MonetDB Public License v1.1
|
data/README.rdoc
CHANGED
@@ -1,154 +1,27 @@
|
|
1
|
-
==
|
2
|
-
This directory contains the a ruby interface to monetdb5
|
3
|
-
written in pure ruby.
|
1
|
+
== MonetDB
|
4
2
|
|
5
|
-
|
6
|
-
lib/MonetDBConnection.rb
|
7
|
-
lib/MonetDBStatements.rb
|
8
|
-
lib/MonetDBData.rb
|
9
|
-
lib/MonetDBExceptions.rb
|
10
|
-
lib/hasher.rb
|
11
|
-
lib/demo.rb: demo application how to interact with the database
|
3
|
+
A pure Ruby database driver for MonetDB (monetdb5).
|
12
4
|
|
13
|
-
|
5
|
+
=== Installation
|
14
6
|
|
15
|
-
|
7
|
+
==== Using Bundler
|
16
8
|
|
17
|
-
|
9
|
+
Add <tt>MonetDB</tt> in <tt>Gemfile</tt> as a gem dependency:
|
18
10
|
|
19
|
-
|
11
|
+
gem "monetdb"
|
20
12
|
|
21
|
-
|
13
|
+
Run the following in your console to install with Bundler:
|
22
14
|
|
23
|
-
$
|
15
|
+
$ bundle install
|
24
16
|
|
25
|
-
|
17
|
+
=== License
|
26
18
|
|
27
|
-
|
19
|
+
Copyright (c) 2014 Paul Engel, released under the MonetDB Public License v1.1
|
28
20
|
|
29
|
-
|
30
|
-
To use the standalone driver import the 'MonetDB' class and 'rubygems' (in case you installed it using gems).
|
21
|
+
http://gettopup.com – http://github.com/archan937 – http://twitter.com/archan937 – {pm_engel@icloud.com}[mailto:pm_engel@icloud.com]
|
31
22
|
|
32
|
-
|
33
|
-
Invoke query using the database handle to send the statement to the server and get back a result set object.
|
23
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
34
24
|
|
35
|
-
|
36
|
-
Use a row fetching method such as fetch_row or an iterator such as each to access the rows of the result set.
|
37
|
-
If you want a count of the number of rows in the result set: invoke 'num_rows' method.
|
38
|
-
Invoke 'free' to release the result set.
|
39
|
-
|
40
|
-
== Example ==
|
41
|
-
|
42
|
-
require 'MonetDB'
|
43
|
-
|
44
|
-
db = MonetDB.new
|
45
|
-
db.connect(user = "monetdb", passwd = "monetdb", lang = "sql", host="127.0.0.1", port = 50000, db_name = "demo", auth_type = "SHA1")
|
46
|
-
|
47
|
-
# set type_cast=true to enable MonetDB to Ruby type mapping
|
48
|
-
res = db.query("SELECT * from tables;", type_cast = false)
|
49
|
-
|
50
|
-
#puts res.debug_columns_type
|
51
|
-
|
52
|
-
puts "Number of rows returned: " + res.num_rows.to_s
|
53
|
-
puts "Number of fields: " + res.num_fields.to_s
|
54
|
-
|
55
|
-
|
56
|
-
# Get the columns' name
|
57
|
-
col_names = res.name_fields
|
58
|
-
|
59
|
-
|
60
|
-
# Iterate over the record set and retrieve on row at a time
|
61
|
-
puts res.fetch
|
62
|
-
while row = res.fetch do
|
63
|
-
printf "%s \n", row
|
64
|
-
end
|
65
|
-
|
66
|
-
# Release the result set.
|
67
|
-
res.free
|
68
|
-
|
69
|
-
# Disconnect from server
|
70
|
-
db.close
|
71
|
-
|
72
|
-
See lib/demo.rb and the MonetDBDatar class documentation for more examples.
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
== ActiveRecord connector adapter ==
|
77
|
-
Active Record connects business objects and database tables to create a persistable domain model where logic and data are presented in one wrapping. It‘s an implementation of the object-relational mapping (ORM) pattern.
|
78
|
-
|
79
|
-
Required files:
|
80
|
-
|
81
|
-
adapter/lib/active_record/monetdb_adapter.rb
|
82
|
-
|
83
|
-
Usage example follows:
|
84
|
-
require 'active_record'
|
85
|
-
|
86
|
-
ActiveRecord::Base.logger = Logger.new(STDERR)
|
87
|
-
ActiveRecord::Base.colorize_logging = true
|
88
|
-
|
89
|
-
ActiveRecord::Base.establish_connection(
|
90
|
-
:adapter => "monetdb",
|
91
|
-
:host => "localhost",
|
92
|
-
:database => "demo"
|
93
|
-
)
|
94
|
-
|
95
|
-
# Create a new table
|
96
|
-
class AddTests < ActiveRecord::Migration
|
97
|
-
def self.up
|
98
|
-
create_table :tests do |table|
|
99
|
-
table.column :name, :string
|
100
|
-
table.column :surname, :string
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
def self.down
|
105
|
-
drop_table :tests
|
106
|
-
end
|
107
|
-
|
108
|
-
end
|
109
|
-
|
110
|
-
AddTests.up
|
111
|
-
|
112
|
-
# Migration: add a column name with a default value
|
113
|
-
class AddAge < ActiveRecord::Migration
|
114
|
-
def self.up
|
115
|
-
add_column :tests, :age, :smallint, :default => 18
|
116
|
-
end
|
117
|
-
|
118
|
-
def self.down
|
119
|
-
remove_column :tests, :age
|
120
|
-
end
|
121
|
-
|
122
|
-
end
|
123
|
-
|
124
|
-
class Test < ActiveRecord::Base
|
125
|
-
end
|
126
|
-
|
127
|
-
# Insert an entry in the table
|
128
|
-
Test.create(:name => 'X', :surname => 'Y')
|
129
|
-
|
130
|
-
# add a column
|
131
|
-
AddAge.up
|
132
|
-
|
133
|
-
# return the first result of the query SELECT * from tables
|
134
|
-
row = Test.find(:first)
|
135
|
-
printf "SELECT * from tests LIMIT 1:\n"
|
136
|
-
printf "Name: %s, Surname: %s, Age: %s\n", row.name, row.surname, row.age
|
137
|
-
|
138
|
-
# Drop the table
|
139
|
-
AddTests.down
|
140
|
-
|
141
|
-
== Rubygem ==
|
142
|
-
|
143
|
-
The standalone ruby driver can be distributed as a ruby gem.
|
144
|
-
A gem file is already available; however, it can be generated
|
145
|
-
starting from the ruby-monetdb-sql-0.1.gemspec file:
|
146
|
-
|
147
|
-
$ gem build ruby-monetdb-sql-0.1.gemspec
|
148
|
-
|
149
|
-
To install the file run the command:
|
150
|
-
|
151
|
-
$ gem install ruby-monetdb-sql-0.1.gem
|
152
|
-
|
153
|
-
Documentation in ri and html format will be generated and installed as well
|
25
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
154
26
|
|
27
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/lib/monetdb/data.rb
CHANGED
@@ -60,7 +60,7 @@ class MonetDB
|
|
60
60
|
@record_set = record_set.split("\t]\n")
|
61
61
|
|
62
62
|
if @record_set.length != @query['rows'].to_i
|
63
|
-
raise
|
63
|
+
raise MonetDB::QueryError, "Warning: Query #{@query['id']} declared to result in #{@query['rows']} but #{@record_set.length} returned instead"
|
64
64
|
end
|
65
65
|
elsif (@lang == XQUERY and ! XQUERY_OUTPUT_SEQ)
|
66
66
|
return data # return an xml file
|
@@ -136,7 +136,7 @@ class MonetDB
|
|
136
136
|
end
|
137
137
|
@index = Integer(rows.length)
|
138
138
|
else
|
139
|
-
raise
|
139
|
+
raise MonetDB::DataError, "There is no record set currently available"
|
140
140
|
end
|
141
141
|
rows
|
142
142
|
end
|
@@ -183,7 +183,7 @@ class MonetDB
|
|
183
183
|
@action = Q_CREATE
|
184
184
|
end
|
185
185
|
elsif row[0].chr == MSG_INFO
|
186
|
-
raise
|
186
|
+
raise MonetDB::QueryError, row
|
187
187
|
elsif row[0].chr == MSG_SCHEMA_HEADER
|
188
188
|
# process header data
|
189
189
|
@header << row
|
data/lib/monetdb/version.rb
CHANGED