duckdb 0.0.7 → 0.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0a27e917703a870dba56470e00cb4ae70f5b62dcb256d39da63cc88a0a888b5e
4
- data.tar.gz: 8dc0b2f58cc6345540d62cdee126951de02e83b61d555da747ebc7f9a3d486a8
3
+ metadata.gz: 165ee505735c050cb91285841186a9385d46ec4c674183fa31503753a3eb3a79
4
+ data.tar.gz: bca9cdb4ecf241dbe581ad0e2a5b3b600d25a75840bef6bdfed744566cfea621
5
5
  SHA512:
6
- metadata.gz: 45ee35ed43062e134e6c672f16ad92c99a7552607ed221795be8a22bc1b0b33b58b946e323cffc07fb032ad00833f1ec6b667fdceac537cf2dd1968663c44dd7
7
- data.tar.gz: b57c3c55f4cda72fddf72909b16182448b5466c0d14b59afc2776f312c8640af6353786e862a086d782fe9f6f4670fd7d8f6d03fe6f8be47464b3aadcf039d7c
6
+ metadata.gz: 81ea7c4bf67e976715f0ccbddb10992cd10ec228e20787c0403dbee799f2db3b37c72103e31352e7931a32df6e8c9ef2e26281c1812d96339c98be312d50b865
7
+ data.tar.gz: 2e788022c4977e9ac31c63bce5a1d5251b5866536d959316f228a0e46688426829a4b754305d3681973d6efecd8fdcb24a4f1c8c494d5128481410adf5bfdd49
@@ -0,0 +1,34 @@
1
+ name: MacOS
2
+
3
+ on: [push]
4
+
5
+ jobs:
6
+ build:
7
+ runs-on: macos-latest
8
+ strategy:
9
+ matrix:
10
+ ruby: ['2.5.8', '2.6.6', '2.7.2', '3.0.0', 'head']
11
+
12
+ steps:
13
+ - uses: actions/checkout@v2
14
+
15
+ - name: Set up Ruby
16
+ uses: ruby/setup-ruby@v1
17
+ with:
18
+ ruby-version: ${{ matrix.ruby }}
19
+
20
+ - name: Install duckdb
21
+ env:
22
+ DUCKDB_VERSION: 0.2.4
23
+ run: |
24
+ brew install duckdb
25
+ git clone -b v${DUCKDB_VERSION} https://github.com/cwida/duckdb.git duckdb-v${DUCKDB_VERSION}
26
+ cp duckdb-v${DUCKDB_VERSION}/src/include/duckdb.h /usr/local/include
27
+ mkdir -p /usr/local/include/duckdb/common
28
+ cp duckdb-v${DUCKDB_VERSION}/src/include/duckdb/common/winapi.hpp /usr/local/include/duckdb/common
29
+
30
+ - name: Build and test with Rake with Ruby ${{ matrix.ruby }}
31
+ run: |
32
+ ruby -v
33
+ bundle install --jobs 4 --retry 3
34
+ bundle exec rake
@@ -0,0 +1,66 @@
1
+ name: Ubuntu
2
+
3
+ on: [push]
4
+
5
+ jobs:
6
+ build:
7
+
8
+ runs-on: ubuntu-latest
9
+ strategy:
10
+ matrix:
11
+ ruby: ['2.5.8', '2.6.6', '2.7.2', '3.0.0', 'head']
12
+ duckdb: ['0.2.4', '0.2.3']
13
+
14
+ steps:
15
+ - uses: actions/checkout@v2
16
+
17
+ - name: Set up Ruby
18
+ uses: ruby/setup-ruby@v1
19
+ with:
20
+ ruby-version: ${{ matrix.ruby }}
21
+
22
+ - name: duckdb 0.2.4 cache
23
+ id: duckdb-cache-v0_2_4
24
+ uses: actions/cache@v1.1.0
25
+ with:
26
+ path: duckdb-v0.2.4
27
+ key: ${{ runner.os }}-duckdb-v0_2_4_001
28
+ restore-keys: |
29
+ ${{ runner.os }}-duckdb-v0_2_4
30
+
31
+ - name: duckdb 0.2.3 cache
32
+ id: duckdb-cache-v0_2_3
33
+ uses: actions/cache@v1.1.0
34
+ with:
35
+ path: duckdb-v0.2.3
36
+ key: ${{ runner.os }}-duckdb-v0_2_3_001
37
+ restore-keys: |
38
+ ${{ runner.os }}-duckdb-v0_2_3
39
+
40
+ - name: Build duckdb 0.2.4
41
+ if: steps.duckdb-cache-v0_2_4.outputs.cache-hit != 'true'
42
+ run: |
43
+ git clone -b v0.2.4 https://github.com/cwida/duckdb.git duckdb-tmp-v0.2.4
44
+ cd duckdb-tmp-v0.2.4 && make && cd ..
45
+ rm -rf duckdb-v0.2.4
46
+ mkdir -p duckdb-v0.2.4/build/release/src duckdb-v0.2.4/src
47
+ cp -rip duckdb-tmp-v0.2.4/build/release/src/*.so duckdb-v0.2.4/build/release/src
48
+ cp -rip duckdb-tmp-v0.2.4/src/include duckdb-v0.2.4/src/
49
+
50
+ - name: Build duckdb 0.2.3
51
+ if: steps.duckdb-cache-v0_2_3.outputs.cache-hit != 'true'
52
+ run: |
53
+ git clone -b v0.2.3 https://github.com/cwida/duckdb.git duckdb-tmp-v0.2.3
54
+ cd duckdb-tmp-v0.2.3 && make && cd ..
55
+ rm -rf duckdb-v0.2.3
56
+ mkdir -p duckdb-v0.2.3/build/release/src duckdb-v0.2.3/src
57
+ cp -rip duckdb-tmp-v0.2.3/build/release/src/*.so duckdb-v0.2.3/build/release/src
58
+ cp -rip duckdb-tmp-v0.2.3/src/include duckdb-v0.2.3/src/
59
+
60
+ - name: Build and test with Rake with Ruby ${{ matrix.ruby }}
61
+ env:
62
+ DUCKDB_VERSION: ${{ matrix.duckdb }}
63
+ run: |
64
+ gem install bundler
65
+ bundle install --jobs 4 --retry 3
66
+ bundle exec rake -- --with-duckdb-include=${GITHUB_WORKSPACE}/duckdb-v${DUCKDB_VERSION}/src/include --with-duckdb-lib=${GITHUB_WORKSPACE}/duckdb-v${DUCKDB_VERSION}/build/release/src/
data/.travis.yml CHANGED
@@ -2,16 +2,17 @@ language: ruby
2
2
  cache:
3
3
  bundler: true
4
4
  directories:
5
- - ${HOME}/duckdb-v0.1.5
5
+ - ${HOME}/duckdb-v0.2.3
6
6
  before_install:
7
7
  - yes | gem update --system
8
- - if [[ ! -d ${HOME}/duckdb-v0.1.5/build ]]; then cd ${HOME} && git clone -b v0.1.5 https://github.com/cwida/duckdb.git duckdb-v0.1.5 && cd duckdb-v0.1.5 && make && cd ${TRAVIS_BUILD_DIR}; fi
8
+ - if [[ ! -d ${HOME}/duckdb-v0.2.3/build ]]; then cd ${HOME} && git clone -b v0.2.3 https://github.com/cwida/duckdb.git duckdb-v0.2.3 && cd duckdb-v0.2.3 && make && cd ${TRAVIS_BUILD_DIR}; fi
9
9
 
10
10
  env:
11
- - DUCKDB_VERSION=0.1.5
11
+ - DUCKDB_VERSION=0.2.3
12
12
  rvm:
13
- - 2.5.7
14
- - 2.6.5
15
- - 2.7.0
13
+ - 2.5.8
14
+ - 2.6.6
15
+ - 2.7.2
16
+ - 3.0.0
16
17
  - ruby-head
17
18
  script: bundle exec rake -- --with-duckdb-include=${HOME}/duckdb-v${DUCKDB_VERSION}/src/include --with-duckdb-lib=${HOME}/duckdb-v${DUCKDB_VERSION}/build/release/src/
data/CHANGELOG.md CHANGED
@@ -1,5 +1,45 @@
1
1
  # ChangeLog
2
2
 
3
+ ## 0.0.11
4
+
5
+ - fix failure in test_close in test/duckdb_test/database_test.rb because DuckDB error message was changed.
6
+ - bump DuckDb to v0.2.4
7
+ - add test CI with Ruby 3.0.0
8
+ - add test CI on MacOS.
9
+ - bunp DuckDB to v0.2.3
10
+
11
+ ## 0.0.10
12
+
13
+ - bump DuckDB to v0.2.2
14
+ - fix to build failure on MacOS.
15
+
16
+ ## 0.0.9
17
+
18
+ - bump DuckDB to v0.2.1
19
+ - bump Ruby to v2.7.2
20
+ - bunmp DuckDB to v0.2.0
21
+
22
+ ## 0.0.8.1
23
+
24
+ - update Gemfile.lock
25
+ - unsupport Ruby 2.4
26
+
27
+ ## 0.0.8
28
+
29
+ - remove test with Ruby 2.4.10
30
+ - bump DuckDB to v0.1.8
31
+ - bump DuckDB to v0.1.8
32
+ - bump DuckDB to v0.1.7
33
+ - current ruby-duckdb supports DuckDB version 0.1.5 and 0.1.6
34
+ - support Ruby 2.7.1
35
+ - bump DuckDB to v0.1.6
36
+ - current ruby-duckdb supports DuckDB version 0.1.5 and 0.1.6
37
+ - DuckDB::Connection#connect accepts block
38
+ - add DuckDB::Connection#connect
39
+ - DuckDB::Database#connect accepts block
40
+ - DuckDB::Database.open accepts block
41
+ - update duckdb.gemspec, required ruby version >= 2.4.0
42
+
3
43
  ## 0.0.7
4
44
 
5
45
  - bump DuckDB to v0.1.5
data/Gemfile.lock CHANGED
@@ -1,18 +1,18 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- duckdb (0.0.7)
4
+ duckdb (0.0.11)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- minitest (5.13.0)
10
- rake (13.0.1)
11
- rake-compiler (1.1.0)
9
+ minitest (5.14.3)
10
+ rake (13.0.3)
11
+ rake-compiler (1.1.1)
12
12
  rake
13
13
 
14
14
  PLATFORMS
15
- ruby
15
+ x86_64-linux
16
16
 
17
17
  DEPENDENCIES
18
18
  bundler (~> 2.0)
@@ -22,4 +22,4 @@ DEPENDENCIES
22
22
  rake-compiler
23
23
 
24
24
  BUNDLED WITH
25
- 2.1.4
25
+ 2.2.3
data/README.md CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  [![Build Status](https://travis-ci.com/suketa/ruby-duckdb.svg?branch=master)](https://travis-ci.com/suketa/ruby-duckdb)
4
4
  [![](https://github.com/suketa/ruby-duckdb/workflows/Ubuntu/badge.svg)](https://github.com/suketa/ruby-duckdb/actions?query=workflow%3AUbuntu)
5
+ [![](https://github.com/suketa/ruby-duckdb/workflows/MacOS/badge.svg)](https://github.com/suketa/ruby-duckdb/actions?query=workflow%3AMacOS)
5
6
 
6
7
  ## Description
7
8
 
@@ -42,3 +43,24 @@ result.each do |row|
42
43
  p row
43
44
  end
44
45
  ```
46
+
47
+ Or, you can use block.
48
+
49
+ ```
50
+ require 'duckdb'
51
+
52
+ DuckDB::Database.open do |db|
53
+ db.connect do |con|
54
+ con.query('CREATE TABLE users (id INTEGER, name VARCHAR(30))')
55
+
56
+ con.query("INSERT into users VALUES(1, 'Alice')")
57
+ con.query("INSERT into users VALUES(2, 'Bob')")
58
+ con.query("INSERT into users VALUES(3, 'Cathy')")
59
+
60
+ result = con.query('SELECT * from users')
61
+ result.each do |row|
62
+ p row
63
+ end
64
+ end
65
+ end
66
+ ```
data/duckdb.gemspec CHANGED
@@ -1,32 +1,35 @@
1
- lib = File.expand_path("lib", __dir__)
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
2
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
- require "duckdb/version"
5
+ require 'duckdb/version'
4
6
 
5
7
  Gem::Specification.new do |spec|
6
- spec.name = "duckdb"
8
+ spec.name = 'duckdb'
7
9
  spec.version = DuckDB::VERSION
8
- spec.authors = ["Masaki Suketa"]
9
- spec.email = ["masaki.suketa@nifty.ne.jp"]
10
+ spec.authors = ['Masaki Suketa']
11
+ spec.email = ['masaki.suketa@nifty.ne.jp']
10
12
 
11
- spec.summary = %q{This module is Ruby binding for DuckDB database engine.}
12
- spec.description = "This module is Ruby binding for DuckDB database engine. You must have the DuckDB engine installed to build/use this module."
13
- spec.homepage = "https://github.com/suketa/ruby-duckdb"
14
- spec.license = "MIT"
13
+ spec.summary = 'This module is Ruby binding for DuckDB database engine.'
14
+ spec.description = 'This module is Ruby binding for DuckDB database engine. You must have the DuckDB engine installed to build/use this module.'
15
+ spec.homepage = 'https://github.com/suketa/ruby-duckdb'
16
+ spec.license = 'MIT'
15
17
 
16
- spec.metadata["homepage_uri"] = spec.homepage
17
- spec.metadata["source_code_uri"] = "https://github.com/suketa/ruby-duckdb"
18
- spec.metadata["changelog_uri"] = "https://github.com/suketa/ruby-duckdb/blob/master/CHANGELOG.md"
18
+ spec.metadata['homepage_uri'] = spec.homepage
19
+ spec.metadata['source_code_uri'] = 'https://github.com/suketa/ruby-duckdb'
20
+ spec.metadata['changelog_uri'] = 'https://github.com/suketa/ruby-duckdb/blob/master/CHANGELOG.md'
19
21
 
20
22
  # Specify which files should be added to the gem when it is released.
21
23
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
22
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
24
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
23
25
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
24
26
  end
25
- spec.require_paths = ["lib"]
26
- spec.extensions = ["ext/duckdb/extconf.rb"]
27
+ spec.require_paths = ['lib']
28
+ spec.extensions = ['ext/duckdb/extconf.rb']
29
+ spec.required_ruby_version = '>= 2.5.0'
27
30
 
28
- spec.add_development_dependency "bundler", "~> 2.0"
29
- spec.add_development_dependency "rake", "~> 13.0"
30
- spec.add_development_dependency "rake-compiler"
31
- spec.add_development_dependency "minitest", "~> 5.0"
31
+ spec.add_development_dependency 'bundler', '~> 2.0'
32
+ spec.add_development_dependency 'minitest', '~> 5.0'
33
+ spec.add_development_dependency 'rake', '~> 13.0'
34
+ spec.add_development_dependency 'rake-compiler'
32
35
  end
@@ -1,5 +1,7 @@
1
1
  #include "ruby-duckdb.h"
2
2
 
3
+ VALUE cDuckDBConnection;
4
+
3
5
  static void deallocate(void *ctx)
4
6
  {
5
7
  rubyDuckDBConnection *p = (rubyDuckDBConnection *)ctx;
@@ -87,6 +89,6 @@ void init_duckdb_connection(void)
87
89
  rb_define_alloc_func(cDuckDBConnection, allocate);
88
90
 
89
91
  rb_define_method(cDuckDBConnection, "disconnect", duckdb_connection_disconnect, 0);
90
- rb_define_method(cDuckDBConnection, "connect", duckdb_connection_connect, 1);
92
+ rb_define_private_method(cDuckDBConnection, "_connect", duckdb_connection_connect, 1);
91
93
  rb_define_private_method(cDuckDBConnection, "query_sql", duckdb_connection_query_sql, 1);
92
94
  }
@@ -7,8 +7,6 @@ struct _rubyDuckDBConnection {
7
7
 
8
8
  typedef struct _rubyDuckDBConnection rubyDuckDBConnection;
9
9
 
10
- VALUE cDuckDBConnection;
11
-
12
10
  void init_duckdb_connection(void);
13
11
  VALUE create_connection(VALUE oDuckDBDatabase);
14
12
 
@@ -1,5 +1,7 @@
1
1
  #include "ruby-duckdb.h"
2
2
 
3
+ VALUE cDuckDBDatabase;
4
+
3
5
  static void close_database(rubyDuckDB *p)
4
6
  {
5
7
  duckdb_close(&(p->db));
@@ -64,7 +66,7 @@ void init_duckdb_database(void)
64
66
  {
65
67
  cDuckDBDatabase = rb_define_class_under(mDuckDB, "Database", rb_cObject);
66
68
  rb_define_alloc_func(cDuckDBDatabase, allocate);
67
- rb_define_singleton_method(cDuckDBDatabase, "open", duckdb_database_s_open, -1);
68
- rb_define_method(cDuckDBDatabase, "connect", duckdb_database_connect, 0);
69
+ rb_define_singleton_method(cDuckDBDatabase, "_open", duckdb_database_s_open, -1);
70
+ rb_define_private_method(cDuckDBDatabase, "_connect", duckdb_database_connect, 0);
69
71
  rb_define_method(cDuckDBDatabase, "close", duckdb_database_close, 0);
70
72
  }
@@ -7,8 +7,6 @@ struct _rubyDuckDB {
7
7
 
8
8
  typedef struct _rubyDuckDB rubyDuckDB;
9
9
 
10
- VALUE cDuckDBDatabase;
11
-
12
10
  void init_duckdb_database(void);
13
11
 
14
12
  #endif
data/ext/duckdb/error.c CHANGED
@@ -1,5 +1,7 @@
1
1
  #include "ruby-duckdb.h"
2
2
 
3
+ VALUE eDuckDBError;
4
+
3
5
  void init_duckdb_error(void)
4
6
  {
5
7
  eDuckDBError = rb_define_class_under(mDuckDB, "Error", rb_eStandardError);
data/ext/duckdb/error.h CHANGED
@@ -1,8 +1,6 @@
1
1
  #ifndef RUBY_DUCKDB_ERROR_H
2
2
  #define RUBY_DUCKDB_ERROR_H
3
3
 
4
- VALUE eDuckDBError;
5
-
6
4
  void init_duckdb_error(void);
7
5
 
8
6
  #endif
@@ -81,7 +81,7 @@ static VALUE duckdb_prepared_statement_bind_boolean(VALUE self, VALUE vidx, VALU
81
81
  }
82
82
 
83
83
  if (duckdb_bind_boolean(ctx->prepared_statement, idx, (val == Qtrue)) == DuckDBError) {
84
- rb_raise(eDuckDBError, "fail to bind %ld parameter", idx);
84
+ rb_raise(eDuckDBError, "fail to bind %llu parameter", (unsigned long long)idx);
85
85
  }
86
86
  return self;
87
87
  }
@@ -95,7 +95,7 @@ static VALUE duckdb_prepared_statement_bind_int16(VALUE self, VALUE vidx, VALUE
95
95
  Data_Get_Struct(self, rubyDuckDBPreparedStatement, ctx);
96
96
 
97
97
  if (duckdb_bind_int16(ctx->prepared_statement, idx, i16val) == DuckDBError) {
98
- rb_raise(eDuckDBError, "fail to bind %ld parameter", idx);
98
+ rb_raise(eDuckDBError, "fail to bind %llu parameter", (unsigned long long)idx);
99
99
  }
100
100
  return self;
101
101
  }
@@ -104,12 +104,12 @@ static VALUE duckdb_prepared_statement_bind_int32(VALUE self, VALUE vidx, VALUE
104
104
  {
105
105
  rubyDuckDBPreparedStatement *ctx;
106
106
  idx_t idx = check_index(vidx);
107
- int32_t i32val = NUM2LONG(val);
107
+ int32_t i32val = NUM2INT(val);
108
108
 
109
109
  Data_Get_Struct(self, rubyDuckDBPreparedStatement, ctx);
110
110
 
111
111
  if (duckdb_bind_int32(ctx->prepared_statement, idx, i32val) == DuckDBError) {
112
- rb_raise(eDuckDBError, "fail to bind %ld parameter", idx);
112
+ rb_raise(eDuckDBError, "fail to bind %llu parameter", (unsigned long long)idx);
113
113
  }
114
114
  return self;
115
115
  }
@@ -123,7 +123,7 @@ static VALUE duckdb_prepared_statement_bind_int64(VALUE self, VALUE vidx, VALUE
123
123
  Data_Get_Struct(self, rubyDuckDBPreparedStatement, ctx);
124
124
 
125
125
  if (duckdb_bind_int64(ctx->prepared_statement, idx, i64val) == DuckDBError) {
126
- rb_raise(eDuckDBError, "fail to bind %ld parameter", idx);
126
+ rb_raise(eDuckDBError, "fail to bind %llu parameter", (unsigned long long)idx);
127
127
  }
128
128
  return self;
129
129
  }
@@ -137,7 +137,7 @@ static VALUE duckdb_prepared_statement_bind_float(VALUE self, VALUE vidx, VALUE
137
137
  Data_Get_Struct(self, rubyDuckDBPreparedStatement, ctx);
138
138
 
139
139
  if (duckdb_bind_float(ctx->prepared_statement, idx, (float)dbl) == DuckDBError) {
140
- rb_raise(eDuckDBError, "fail to bind %ld parameter", idx);
140
+ rb_raise(eDuckDBError, "fail to bind %llu parameter", (unsigned long long)idx);
141
141
  }
142
142
  return self;
143
143
  }
@@ -151,7 +151,7 @@ static VALUE duckdb_prepared_statement_bind_double(VALUE self, VALUE vidx, VALUE
151
151
  Data_Get_Struct(self, rubyDuckDBPreparedStatement, ctx);
152
152
 
153
153
  if (duckdb_bind_double(ctx->prepared_statement, idx, dbl) == DuckDBError) {
154
- rb_raise(eDuckDBError, "fail to bind %ld parameter", idx);
154
+ rb_raise(eDuckDBError, "fail to bind %llu parameter", (unsigned long long)idx);
155
155
  }
156
156
  return self;
157
157
  }
@@ -163,7 +163,7 @@ static VALUE duckdb_prepared_statement_bind_varchar(VALUE self, VALUE vidx, VALU
163
163
 
164
164
  Data_Get_Struct(self, rubyDuckDBPreparedStatement, ctx);
165
165
  if (duckdb_bind_varchar(ctx->prepared_statement, idx, StringValuePtr(str)) == DuckDBError) {
166
- rb_raise(eDuckDBError, "fail to bind %ld parameter", idx);
166
+ rb_raise(eDuckDBError, "fail to bind %llu parameter", (unsigned long long)idx);
167
167
  }
168
168
  return self;
169
169
  }
@@ -175,7 +175,7 @@ static VALUE duckdb_prepared_statement_bind_null(VALUE self, VALUE vidx)
175
175
 
176
176
  Data_Get_Struct(self, rubyDuckDBPreparedStatement, ctx);
177
177
  if (duckdb_bind_null(ctx->prepared_statement, idx) == DuckDBError) {
178
- rb_raise(eDuckDBError, "fail to bind %ld parameter", idx);
178
+ rb_raise(eDuckDBError, "fail to bind %llu parameter", (unsigned long long)idx);
179
179
  }
180
180
  return self;
181
181
  }
@@ -10,5 +10,8 @@
10
10
  #include "./prepared_statement.h"
11
11
 
12
12
  extern VALUE mDuckDB;
13
+ extern VALUE cDuckDBDatabase;
14
+ extern VALUE cDuckDBConnection;
15
+ extern VALUE eDuckDBError;
13
16
 
14
17
  #endif
@@ -29,6 +29,21 @@ module DuckDB
29
29
  stmt.execute
30
30
  end
31
31
 
32
+ #
33
+ # connects DuckDB database
34
+ # The first argument is DuckDB::Database object
35
+ #
36
+ def connect(db)
37
+ conn = _connect(db)
38
+ return conn unless block_given?
39
+
40
+ begin
41
+ yield conn
42
+ ensure
43
+ conn.disconnect
44
+ end
45
+ end
46
+
32
47
  alias execute query
33
48
  alias open connect
34
49
  alias close disconnect
@@ -20,5 +20,58 @@ module DuckDB
20
20
  # end
21
21
  #
22
22
  class Database
23
+ private_class_method :_open
24
+
25
+ class << self
26
+ ##
27
+ # Opens database.
28
+ # The first argument is DuckDB database file path to open.
29
+ # If there is no argument, the method opens DuckDB database in memory.
30
+ # The method yields block if block is given.
31
+ #
32
+ # DuckDB::Database.open('duckdb_database.db') #=> DuckDB::Database
33
+ #
34
+ # DuckDB::Database.open #=> opens DuckDB::Database in memory.
35
+ #
36
+ # DuckDB::Database.open do |db|
37
+ # con = db.connect
38
+ # con.query('CREATE TABLE users (id INTEGER, name VARCHAR(30))')
39
+ # end
40
+ #
41
+ def open(*args)
42
+ db = _open(*args)
43
+ return db unless block_given?
44
+
45
+ begin
46
+ yield db
47
+ ensure
48
+ db.close
49
+ end
50
+ end
51
+ end
52
+
53
+ ##
54
+ # connects database.
55
+ #
56
+ # The method yields block and disconnects the database if block given
57
+ #
58
+ # db = DuckDB::Database.open
59
+ #
60
+ # con = db.connect # => DuckDB::Connection
61
+ #
62
+ # db.connect do |con|
63
+ # con.query('CREATE TABLE users (id INTEGER, name VARCHAR(30))')
64
+ # end
65
+ #
66
+ def connect
67
+ conn = _connect
68
+ return conn unless block_given?
69
+
70
+ begin
71
+ yield conn
72
+ ensure
73
+ conn.disconnect
74
+ end
75
+ end
23
76
  end
24
77
  end
@@ -1,5 +1,5 @@
1
1
  module DuckDB
2
2
  # The version string of ruby-duckdb.
3
3
  # Currently, ruby-duckdb is NOT semantic versioning.
4
- VERSION = '0.0.7'.freeze
4
+ VERSION = '0.0.11'.freeze
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: duckdb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masaki Suketa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-07 00:00:00.000000000 Z
11
+ date: 2021-02-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -25,47 +25,47 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '2.0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: rake
28
+ name: minitest
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '13.0'
33
+ version: '5.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '13.0'
40
+ version: '5.0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: rake-compiler
42
+ name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: '13.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: '13.0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: minitest
56
+ name: rake-compiler
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '5.0'
61
+ version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: '5.0'
68
+ version: '0'
69
69
  description: This module is Ruby binding for DuckDB database engine. You must have
70
70
  the DuckDB engine installed to build/use this module.
71
71
  email:
@@ -75,7 +75,8 @@ extensions:
75
75
  - ext/duckdb/extconf.rb
76
76
  extra_rdoc_files: []
77
77
  files:
78
- - ".github/workflows/test_by_github.yml"
78
+ - ".github/workflows/test_on_macos.yml"
79
+ - ".github/workflows/test_on_ubuntu.yml"
79
80
  - ".gitignore"
80
81
  - ".travis.yml"
81
82
  - CHANGELOG.md
@@ -121,14 +122,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
121
122
  requirements:
122
123
  - - ">="
123
124
  - !ruby/object:Gem::Version
124
- version: '0'
125
+ version: 2.5.0
125
126
  required_rubygems_version: !ruby/object:Gem::Requirement
126
127
  requirements:
127
128
  - - ">="
128
129
  - !ruby/object:Gem::Version
129
130
  version: '0'
130
131
  requirements: []
131
- rubygems_version: 3.1.2
132
+ rubygems_version: 3.2.3
132
133
  signing_key:
133
134
  specification_version: 4
134
135
  summary: This module is Ruby binding for DuckDB database engine.
@@ -1,47 +0,0 @@
1
- name: Ubuntu
2
-
3
- on: [push]
4
-
5
- jobs:
6
- build:
7
-
8
- runs-on: ubuntu-latest
9
- strategy:
10
- matrix:
11
- ruby: ['2.5.x', '2.6.x']
12
- duckdb: ['0.1.5']
13
-
14
- steps:
15
- - uses: actions/checkout@v1
16
-
17
- - name: Set up Ruby
18
- uses: actions/setup-ruby@v1
19
- with:
20
- ruby-version: ${{ matrix.ruby }}
21
-
22
- - name: duckdb 0.1.5 cache
23
- id: duckdb-cache-v0_1_5
24
- uses: actions/cache@v1.1.0
25
- with:
26
- path: duckdb-v0.1.5
27
- key: ${{ runner.os }}-duckdb-v0_1_5_001
28
- restore-keys: |
29
- ${{ runner.os }}-duckdb-v0_1_5
30
-
31
- - name: Build duckdb 0.1.5
32
- if: steps.duckdb-cache-v0_1_5.outputs.cache-hit != 'true'
33
- run: |
34
- git clone -b v0.1.5 https://github.com/cwida/duckdb.git duckdb-tmp-v0.1.5
35
- cd duckdb-tmp-v0.1.5 && make && cd ..
36
- rm -rf duckdb-v0.1.5
37
- mkdir -p duckdb-v0.1.5/build/release/src duckdb-v0.1.5/src
38
- cp -rip duckdb-tmp-v0.1.5/build/release/src/*.so duckdb-v0.1.5/build/release/src
39
- cp -rip duckdb-tmp-v0.1.5/src/include duckdb-v0.1.5/src/
40
-
41
- - name: Build and test with Rake with Ruby ${{ matrix.ruby }}
42
- env:
43
- DUCKDB_VERSION: ${{ matrix.duckdb }}
44
- run: |
45
- gem install bundler
46
- bundle install --jobs 4 --retry 3
47
- bundle exec rake -- --with-duckdb-include=${GITHUB_WORKSPACE}/duckdb-v${DUCKDB_VERSION}/src/include --with-duckdb-lib=${GITHUB_WORKSPACE}/duckdb-v${DUCKDB_VERSION}/build/release/src/