extralite 1.11 → 1.12
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 +4 -4
- data/.github/workflows/test.yml +1 -1
- data/CHANGELOG.md +5 -0
- data/Gemfile.lock +3 -3
- data/README.md +8 -2
- data/ext/extralite/extconf.rb +3 -109
- data/ext/extralite/extralite.c +11 -0
- data/ext/extralite/sqlite3.c +237479 -0
- data/ext/extralite/sqlite3.h +12492 -0
- data/extralite.gemspec +1 -1
- data/lib/extralite/version.rb +1 -1
- data/test/extensions/text.dylib +0 -0
- data/test/extensions/text.so +0 -0
- data/test/helper.rb +2 -0
- data/test/test_database.rb +14 -0
- data/test/test_extralite.rb +14 -0
- metadata +13 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed6cb05e12c36bbbc92701af98639a9a92b91d9ba0fca0362b35fb12f3af676e
|
4
|
+
data.tar.gz: 6d7976fc5b39aa414a5a3431a9c5a1a6c517166d4e82de621b22da3be50fe38b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9baa147f13fa4498264e6e942e9c154bcdcd458f503944be9385f5ea61b82a8e6d381f77a75ad7a4c7643aa124cc2a4d5aa8ffb58400efa641dcb62fad810437
|
7
|
+
data.tar.gz: 789d203582c86f54a8f234b67d7b54b03150b900d25a5c76e81a57d779d1735fa7a8dc9822d121df7d08af4513481bf4c0a1a6d2fb1d6dfc54d80022b2b6e559
|
data/.github/workflows/test.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
extralite (1.
|
4
|
+
extralite (1.12)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
9
|
docile (1.4.0)
|
10
|
-
json (2.
|
10
|
+
json (2.6.1)
|
11
11
|
minitest (5.15.0)
|
12
12
|
rake (13.0.6)
|
13
13
|
rake-compiler (1.1.6)
|
@@ -34,4 +34,4 @@ DEPENDENCIES
|
|
34
34
|
yard (= 0.9.27)
|
35
35
|
|
36
36
|
BUNDLED WITH
|
37
|
-
2.
|
37
|
+
2.3.3
|
data/README.md
CHANGED
@@ -29,6 +29,8 @@ interacting with an SQLite3 database.
|
|
29
29
|
|
30
30
|
## Features
|
31
31
|
|
32
|
+
- Zero dependencies: Extralite bundles SQLite3 version 3.37.2 - no need to
|
33
|
+
install any `libsqlite3` packages.
|
32
34
|
- A variety of methods for different data access patterns: rows as hashes, rows
|
33
35
|
as arrays, single row, single column, single value.
|
34
36
|
- Super fast - [up to 12.5x faster](#performance) than the
|
@@ -45,13 +47,16 @@ interacting with an SQLite3 database.
|
|
45
47
|
- Get number of rows changed by last query.
|
46
48
|
- Load extensions (loading of extensions is autmatically enabled. You can find
|
47
49
|
some useful extensions here: https://github.com/nalgeon/sqlean.)
|
48
|
-
- Includes a [Sequel adapter](#usage-with-sequel)
|
50
|
+
- Includes a [Sequel adapter](#usage-with-sequel).
|
49
51
|
|
50
52
|
## Usage
|
51
53
|
|
52
54
|
```ruby
|
53
55
|
require 'extralite'
|
54
56
|
|
57
|
+
# get sqlite3 version
|
58
|
+
Extralite.sqlite3_version #=> "3.37.2"
|
59
|
+
|
55
60
|
# open a database
|
56
61
|
db = Extralite::Database.new('/tmp/my.db')
|
57
62
|
|
@@ -113,7 +118,7 @@ Extralite includes an adapter for
|
|
113
118
|
just use the `extralite` scheme instead of `sqlite`:
|
114
119
|
|
115
120
|
```ruby
|
116
|
-
DB = Sequel.connect('extralite
|
121
|
+
DB = Sequel.connect('extralite://blog.db')
|
117
122
|
articles = DB[:articles]
|
118
123
|
p articles.to_a
|
119
124
|
```
|
@@ -137,6 +142,7 @@ Here's a table summarizing the differences between the two gems:
|
|
137
142
|
|
138
143
|
| |sqlite3-ruby|Extralite|
|
139
144
|
|-|-|-|
|
145
|
+
|SQLite3 dependency|depends on OS-installed libsqlite3|bundles latest version of SQLite3|
|
140
146
|
|API design|multiple classes|single class|
|
141
147
|
|Query results|row as hash, row as array, single row, single value|row as hash, row as array, __single column__, single row, single value|
|
142
148
|
|execute multiple statements|separate API (#execute_batch)|integrated|
|
data/ext/extralite/extconf.rb
CHANGED
@@ -1,115 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# require 'rubygems'
|
4
|
-
# require 'mkmf'
|
5
|
-
|
6
|
-
# # $CFLAGS << "-Wdiscarded-qualifier"
|
7
|
-
# # $CFLAGS << " -Wno-comment"
|
8
|
-
# # $CFLAGS << " -Wno-unused-result"
|
9
|
-
# # $CFLAGS << " -Wno-dangling-else"
|
10
|
-
# # $CFLAGS << " -Wno-parentheses"
|
11
|
-
|
12
|
-
# dir_config 'extralite_ext'
|
13
|
-
# create_makefile 'extralite_ext'
|
14
|
-
|
15
|
-
ENV['RC_ARCHS'] = '' if RUBY_PLATFORM =~ /darwin/
|
16
|
-
|
17
3
|
require 'mkmf'
|
18
4
|
|
19
|
-
|
20
|
-
|
21
|
-
RbConfig::MAKEFILE_CONFIG['CC'] = ENV['CC'] if ENV['CC']
|
22
|
-
|
23
|
-
ldflags = cppflags = nil
|
24
|
-
if RbConfig::CONFIG["host_os"] =~ /darwin/
|
25
|
-
begin
|
26
|
-
if with_config('sqlcipher')
|
27
|
-
brew_prefix = `brew --prefix sqlcipher`.chomp
|
28
|
-
ldflags = "#{brew_prefix}/lib"
|
29
|
-
cppflags = "#{brew_prefix}/include/sqlcipher"
|
30
|
-
pkg_conf = "#{brew_prefix}/lib/pkgconfig"
|
31
|
-
else
|
32
|
-
brew_prefix = `brew --prefix sqlite3`.chomp
|
33
|
-
ldflags = "#{brew_prefix}/lib"
|
34
|
-
cppflags = "#{brew_prefix}/include"
|
35
|
-
pkg_conf = "#{brew_prefix}/lib/pkgconfig"
|
36
|
-
end
|
37
|
-
|
38
|
-
# pkg_config should be less error prone than parsing compiler
|
39
|
-
# commandline options, but we need to set default ldflags and cpp flags
|
40
|
-
# in case the user doesn't have pkg-config installed
|
41
|
-
ENV['PKG_CONFIG_PATH'] ||= pkg_conf
|
42
|
-
rescue
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
if with_config('sqlcipher')
|
47
|
-
pkg_config("sqlcipher")
|
48
|
-
else
|
49
|
-
pkg_config("sqlite3")
|
50
|
-
end
|
51
|
-
|
52
|
-
# --with-sqlite3-{dir,include,lib}
|
53
|
-
if with_config('sqlcipher')
|
54
|
-
$CFLAGS << ' -DUSING_SQLCIPHER'
|
55
|
-
dir_config("sqlcipher", cppflags, ldflags)
|
56
|
-
else
|
57
|
-
dir_config("sqlite3", cppflags, ldflags)
|
58
|
-
end
|
59
|
-
|
60
|
-
if RbConfig::CONFIG["host_os"] =~ /mswin/
|
61
|
-
$CFLAGS << ' -W3'
|
62
|
-
end
|
63
|
-
|
64
|
-
if RUBY_VERSION < '2.7'
|
65
|
-
$CFLAGS << ' -DTAINTING_SUPPORT'
|
66
|
-
end
|
67
|
-
|
68
|
-
def asplode missing
|
69
|
-
if RUBY_PLATFORM =~ /mingw|mswin/
|
70
|
-
abort "#{missing} is missing. Install SQLite3 from " +
|
71
|
-
"http://www.sqlite.org/ first."
|
72
|
-
else
|
73
|
-
abort <<-error
|
74
|
-
#{missing} is missing. Try 'brew install sqlite3',
|
75
|
-
'yum install sqlite-devel' or 'apt-get install libsqlite3-dev'
|
76
|
-
and check your shared library search path (the
|
77
|
-
location where your sqlite3 shared library is located).
|
78
|
-
error
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
asplode('sqlite3.h') unless find_header 'sqlite3.h'
|
83
|
-
find_library 'pthread', 'pthread_create' # 1.8 support. *shrug*
|
84
|
-
|
85
|
-
have_library 'dl' # for static builds
|
86
|
-
|
87
|
-
if with_config('sqlcipher')
|
88
|
-
asplode('sqlcipher') unless find_library 'sqlcipher', 'sqlite3_libversion_number'
|
89
|
-
else
|
90
|
-
asplode('sqlite3') unless find_library 'sqlite3', 'sqlite3_libversion_number'
|
91
|
-
end
|
92
|
-
|
93
|
-
# Functions defined in 1.9 but not 1.8
|
94
|
-
have_func('rb_proc_arity')
|
95
|
-
|
96
|
-
# Functions defined in 2.1 but not 2.0
|
97
|
-
have_func('rb_integer_pack')
|
98
|
-
|
99
|
-
# These functions may not be defined
|
100
|
-
have_func('sqlite3_initialize')
|
101
|
-
have_func('sqlite3_backup_init')
|
102
|
-
have_func('sqlite3_column_database_name')
|
103
|
-
have_func('sqlite3_enable_load_extension')
|
104
|
-
have_func('sqlite3_load_extension')
|
105
|
-
|
106
|
-
unless have_func('sqlite3_open_v2')
|
107
|
-
abort "Please use a newer version of SQLite3"
|
108
|
-
end
|
109
|
-
|
110
|
-
have_func('sqlite3_prepare_v2')
|
111
|
-
have_type('sqlite3_int64', 'sqlite3.h')
|
112
|
-
have_type('sqlite3_uint64', 'sqlite3.h')
|
5
|
+
$CFLAGS << " -Wno-undef"
|
6
|
+
$CFLAGS << " -Wno-discarded-qualifiers"
|
113
7
|
|
114
8
|
dir_config('extralite_ext')
|
115
|
-
create_makefile('extralite_ext')
|
9
|
+
create_makefile('extralite_ext')
|
data/ext/extralite/extralite.c
CHANGED
@@ -51,6 +51,15 @@ static VALUE Database_allocate(VALUE klass) {
|
|
51
51
|
} \
|
52
52
|
}
|
53
53
|
|
54
|
+
/* call-seq: sqlite3_version
|
55
|
+
*
|
56
|
+
* Returns the sqlite3 version used by Extralite.
|
57
|
+
*/
|
58
|
+
|
59
|
+
VALUE Extralite_sqlite3_version(VALUE self) {
|
60
|
+
return rb_str_new_cstr(sqlite3_version);
|
61
|
+
}
|
62
|
+
|
54
63
|
/* call-seq: initialize(path)
|
55
64
|
*
|
56
65
|
* Initializes a new SQLite database with the given path.
|
@@ -658,6 +667,8 @@ VALUE Database_load_extension(VALUE self, VALUE path) {
|
|
658
667
|
|
659
668
|
void Init_Extralite() {
|
660
669
|
VALUE mExtralite = rb_define_module("Extralite");
|
670
|
+
rb_define_singleton_method(mExtralite, "sqlite3_version", Extralite_sqlite3_version, 0);
|
671
|
+
|
661
672
|
VALUE cDatabase = rb_define_class_under(mExtralite, "Database", rb_cObject);
|
662
673
|
rb_define_alloc_func(cDatabase, Database_allocate);
|
663
674
|
|