aim-sqlite3 2.9.6.1.rc1-aarch64-linux-gnu

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.
@@ -0,0 +1,96 @@
1
+ require "sqlite3/constants"
2
+ require "sqlite3/errors"
3
+
4
+ module SQLite3
5
+ # The ResultSet object encapsulates the enumerability of a query's output.
6
+ # It is a simple cursor over the data that the query returns. It will
7
+ # very rarely (if ever) be instantiated directly. Instead, clients should
8
+ # obtain a ResultSet instance via Statement#execute.
9
+ class ResultSet
10
+ include Enumerable
11
+
12
+ # Create a new ResultSet attached to the given database, using the
13
+ # given sql text.
14
+ def initialize db, stmt
15
+ @db = db
16
+ @stmt = stmt
17
+ end
18
+
19
+ # Reset the cursor, so that a result set which has reached end-of-file
20
+ # can be rewound and reiterated.
21
+ def reset(*bind_params)
22
+ @stmt.reset!
23
+ @stmt.bind_params(*bind_params)
24
+ end
25
+
26
+ # Query whether the cursor has reached the end of the result set or not.
27
+ def eof?
28
+ @stmt.done?
29
+ end
30
+
31
+ # Obtain the next row from the cursor. If there are no more rows to be
32
+ # had, this will return +nil+.
33
+ #
34
+ # The returned value will be an array, unless Database#results_as_hash has
35
+ # been set to +true+, in which case the returned value will be a hash.
36
+ #
37
+ # For arrays, the column names are accessible via the +fields+ property,
38
+ # and the column types are accessible via the +types+ property.
39
+ #
40
+ # For hashes, the column names are the keys of the hash, and the column
41
+ # types are accessible via the +types+ property.
42
+ def next
43
+ @stmt.step
44
+ end
45
+
46
+ # Required by the Enumerable mixin. Provides an internal iterator over the
47
+ # rows of the result set.
48
+ def each
49
+ while (node = self.next)
50
+ yield node
51
+ end
52
+ end
53
+
54
+ # Provides an internal iterator over the rows of the result set where
55
+ # each row is yielded as a hash.
56
+ def each_hash
57
+ while (node = next_hash)
58
+ yield node
59
+ end
60
+ end
61
+
62
+ # Closes the statement that spawned this result set.
63
+ # <em>Use with caution!</em> Closing a result set will automatically
64
+ # close any other result sets that were spawned from the same statement.
65
+ def close
66
+ @stmt.close
67
+ end
68
+
69
+ # Queries whether the underlying statement has been closed or not.
70
+ def closed?
71
+ @stmt.closed?
72
+ end
73
+
74
+ # Returns the types of the columns returned by this result set.
75
+ def types
76
+ @stmt.types
77
+ end
78
+
79
+ # Returns the names of the columns returned by this result set.
80
+ def columns
81
+ @stmt.columns
82
+ end
83
+
84
+ # Return the next row as a hash
85
+ def next_hash
86
+ row = @stmt.step
87
+ return nil if @stmt.done?
88
+
89
+ @stmt.columns.zip(row).to_h
90
+ end
91
+ end
92
+
93
+ class HashResultSet < ResultSet # :nodoc:
94
+ alias_method :next, :next_hash
95
+ end
96
+ end
@@ -0,0 +1,208 @@
1
+ require "sqlite3/errors"
2
+ require "sqlite3/resultset"
3
+
4
+ class String
5
+ def to_blob
6
+ SQLite3::Blob.new(self)
7
+ end
8
+ end
9
+
10
+ module SQLite3
11
+ # A statement represents a prepared-but-unexecuted SQL query. It will rarely
12
+ # (if ever) be instantiated directly by a client, and is most often obtained
13
+ # via the Database#prepare method.
14
+ class Statement
15
+ include Enumerable
16
+
17
+ # This is any text that followed the first valid SQL statement in the text
18
+ # with which the statement was initialized. If there was no trailing text,
19
+ # this will be the empty string.
20
+ attr_reader :remainder
21
+
22
+ # call-seq: SQLite3::Statement.new(db, sql)
23
+ #
24
+ # Create a new statement attached to the given Database instance, and which
25
+ # encapsulates the given SQL text. If the text contains more than one
26
+ # statement (i.e., separated by semicolons), then the #remainder property
27
+ # will be set to the trailing text.
28
+ def initialize(db, sql)
29
+ raise ArgumentError, "prepare called on a closed database" if db.closed?
30
+
31
+ sql = sql.encode(Encoding::UTF_8) if sql && sql.encoding != Encoding::UTF_8
32
+
33
+ @connection = db
34
+ @columns = nil
35
+ @types = nil
36
+ @remainder = prepare db, sql
37
+ end
38
+
39
+ # Binds the given variables to the corresponding placeholders in the SQL
40
+ # text.
41
+ #
42
+ # See Database#execute for a description of the valid placeholder
43
+ # syntaxes.
44
+ #
45
+ # Type mapping from Ruby to SQLite3:
46
+ # - +nil+ → NULL
47
+ # - Integer → INTEGER (or REAL when outside the signed int64 range)
48
+ # - Float → REAL
49
+ # - SQLite3::Blob → BLOB
50
+ # - String with Encoding::ASCII_8BIT
51
+ # (a.k.a. BINARY) → BLOB
52
+ # - String with Encoding::UTF_16LE
53
+ # or Encoding::UTF_16BE → TEXT (bound as UTF-16)
54
+ # - String (all other encodings) → TEXT (re-encoded to UTF-8 if needed)
55
+ # - Any other type → raises RuntimeError
56
+ #
57
+ # Note: a String with Encoding::ASCII_8BIT (BINARY) is always bound as a
58
+ # BLOB, even when its bytes are all valid ASCII. If you want such a string
59
+ # compared or stored as TEXT, re-encode it before binding:
60
+ #
61
+ # stmt.bind_params(my_binary_str.encode(Encoding::UTF_8))
62
+ #
63
+ # Example:
64
+ #
65
+ # stmt = db.prepare( "select * from table where a=? and b=?" )
66
+ # stmt.bind_params( 15, "hello" )
67
+ #
68
+ # See also #execute, #bind_param, Statement#bind_param, and
69
+ # Statement#bind_params.
70
+ def bind_params(*bind_vars)
71
+ index = 1
72
+ bind_vars.flatten.each do |var|
73
+ if Hash === var
74
+ var.each { |key, val| bind_param key, val }
75
+ else
76
+ bind_param index, var
77
+ index += 1
78
+ end
79
+ end
80
+ end
81
+
82
+ # Execute the statement. This creates a new ResultSet object for the
83
+ # statement's virtual machine. If a block was given, the new ResultSet will
84
+ # be yielded to it; otherwise, the ResultSet will be returned.
85
+ #
86
+ # Any parameters will be bound to the statement using #bind_params.
87
+ #
88
+ # Example:
89
+ #
90
+ # stmt = db.prepare( "select * from table" )
91
+ # stmt.execute do |result|
92
+ # ...
93
+ # end
94
+ #
95
+ # See also #bind_params, #execute!.
96
+ def execute(*bind_vars)
97
+ reset! if active? || done?
98
+
99
+ bind_params(*bind_vars) unless bind_vars.empty?
100
+ results = @connection.build_result_set self
101
+
102
+ step if column_count == 0
103
+
104
+ yield results if block_given?
105
+ results
106
+ end
107
+
108
+ # Execute the statement. If no block was given, this returns an array of
109
+ # rows returned by executing the statement. Otherwise, each row will be
110
+ # yielded to the block.
111
+ #
112
+ # Any parameters will be bound to the statement using #bind_params.
113
+ #
114
+ # Example:
115
+ #
116
+ # stmt = db.prepare( "select * from table" )
117
+ # stmt.execute! do |row|
118
+ # ...
119
+ # end
120
+ #
121
+ # See also #bind_params, #execute.
122
+ def execute!(*bind_vars, &block)
123
+ execute(*bind_vars)
124
+ block ? each(&block) : to_a
125
+ end
126
+
127
+ # Returns true if the statement is currently active, meaning it has an
128
+ # open result set.
129
+ def active?
130
+ !done?
131
+ end
132
+
133
+ # Return an array of the column names for this statement. Note that this
134
+ # may execute the statement in order to obtain the metadata; this makes it
135
+ # a (potentially) expensive operation.
136
+ def columns
137
+ get_metadata unless @columns
138
+ @columns
139
+ end
140
+
141
+ def each
142
+ loop do
143
+ val = step
144
+ break self if done?
145
+ yield val
146
+ end
147
+ end
148
+
149
+ # Return an array of the data types for each column in this statement. Note
150
+ # that this may execute the statement in order to obtain the metadata; this
151
+ # makes it a (potentially) expensive operation.
152
+ def types
153
+ must_be_open!
154
+ get_metadata unless @types
155
+ @types
156
+ end
157
+
158
+ # Performs a sanity check to ensure that the statement is not
159
+ # closed. If it is, an exception is raised.
160
+ def must_be_open! # :nodoc:
161
+ if closed?
162
+ raise SQLite3::Exception, "cannot use a closed statement"
163
+ end
164
+ end
165
+
166
+ # Returns a Hash containing information about the statement.
167
+ # The contents of the hash are implementation specific and may change in
168
+ # the future without notice. The hash includes information about internal
169
+ # statistics about the statement such as:
170
+ # - +fullscan_steps+: the number of times that SQLite has stepped forward
171
+ # in a table as part of a full table scan
172
+ # - +sorts+: the number of sort operations that have occurred
173
+ # - +autoindexes+: the number of rows inserted into transient indices
174
+ # that were created automatically in order to help joins run faster
175
+ # - +vm_steps+: the number of virtual machine operations executed by the
176
+ # prepared statement
177
+ # - +reprepares+: the number of times that the prepare statement has been
178
+ # automatically regenerated due to schema changes or changes to bound
179
+ # parameters that might affect the query plan
180
+ # - +runs+: the number of times that the prepared statement has been run
181
+ # - +filter_misses+: the number of times that the Bloom filter returned
182
+ # a find, and thus the join step had to be processed as normal
183
+ # - +filter_hits+: the number of times that a join step was bypassed
184
+ # because a Bloom filter returned not-found
185
+ def stat key = nil
186
+ if key
187
+ stat_for(key)
188
+ else
189
+ stats_as_hash
190
+ end
191
+ end
192
+
193
+ private
194
+
195
+ # A convenience method for obtaining the metadata about the query. Note
196
+ # that this will actually execute the SQL, which means it can be a
197
+ # (potentially) expensive operation.
198
+ def get_metadata
199
+ @columns = Array.new(column_count) do |column|
200
+ column_name column
201
+ end
202
+ @types = Array.new(column_count) do |column|
203
+ val = column_decltype(column)
204
+ val&.downcase
205
+ end
206
+ end
207
+ end
208
+ end
@@ -0,0 +1,54 @@
1
+ require "sqlite3/constants"
2
+
3
+ module SQLite3
4
+ class Value
5
+ attr_reader :handle
6
+
7
+ def initialize(db, handle)
8
+ @driver = db.driver
9
+ @handle = handle
10
+ end
11
+
12
+ def null?
13
+ type == :null
14
+ end
15
+
16
+ def to_blob
17
+ @driver.value_blob(@handle)
18
+ end
19
+
20
+ def length(utf16 = false)
21
+ if utf16
22
+ @driver.value_bytes16(@handle)
23
+ else
24
+ @driver.value_bytes(@handle)
25
+ end
26
+ end
27
+
28
+ def to_f
29
+ @driver.value_double(@handle)
30
+ end
31
+
32
+ def to_i
33
+ @driver.value_int(@handle)
34
+ end
35
+
36
+ def to_int64
37
+ @driver.value_int64(@handle)
38
+ end
39
+
40
+ def to_s(utf16 = false)
41
+ @driver.value_text(@handle, utf16)
42
+ end
43
+
44
+ def type
45
+ case @driver.value_type(@handle)
46
+ when Constants::ColumnType::INTEGER then :int
47
+ when Constants::ColumnType::FLOAT then :float
48
+ when Constants::ColumnType::TEXT then :text
49
+ when Constants::ColumnType::BLOB then :blob
50
+ when Constants::ColumnType::NULL then :null
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,4 @@
1
+ module SQLite3
2
+ # (String) the version of the sqlite3 gem, e.g. "2.1.1"
3
+ VERSION = "2.9.6.1.rc1"
4
+ end
@@ -0,0 +1,17 @@
1
+ module SQLite3
2
+ # a hash of descriptive metadata about the current version of the sqlite3 gem
3
+ VERSION_INFO = {
4
+ ruby: RUBY_DESCRIPTION,
5
+ gem: {
6
+ version: SQLite3::VERSION
7
+ },
8
+ sqlite: {
9
+ compiled: SQLite3::SQLITE_VERSION,
10
+ loaded: SQLite3::SQLITE_LOADED_VERSION,
11
+ packaged: SQLite3::SQLITE_PACKAGED_LIBRARIES,
12
+ precompiled: SQLite3::SQLITE_PRECOMPILED_LIBRARIES,
13
+ sqlcipher: SQLite3.sqlcipher?,
14
+ threadsafe: SQLite3.threadsafe?
15
+ }
16
+ }
17
+ end
data/lib/sqlite3.rb ADDED
@@ -0,0 +1,20 @@
1
+ # support multiple ruby version (fat binaries under windows)
2
+ begin
3
+ RUBY_VERSION =~ /(\d+\.\d+)/
4
+ require "sqlite3/#{$1}/sqlite3_native"
5
+ rescue LoadError
6
+ require "sqlite3/sqlite3_native"
7
+ end
8
+
9
+ require "sqlite3/database"
10
+ require "sqlite3/version"
11
+
12
+ module SQLite3
13
+ # Was sqlite3 compiled with thread safety on?
14
+ def self.threadsafe?
15
+ threadsafe > 0
16
+ end
17
+ end
18
+
19
+ require "sqlite3/version_info"
20
+ require "sqlite3/cli"
metadata ADDED
@@ -0,0 +1,105 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: aim-sqlite3
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.9.6.1.rc1
5
+ platform: aarch64-linux-gnu
6
+ authors:
7
+ - Jamis Buck
8
+ - Luis Lavena
9
+ - Aaron Patterson
10
+ - Mike Dalessio
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 1980-01-02 00:00:00.000000000 Z
14
+ dependencies: []
15
+ description: |
16
+ Ruby library to interface with the SQLite3 database engine (http://www.sqlite.org). Precompiled
17
+ binaries are available for common platforms for recent versions of Ruby.
18
+ executables: []
19
+ extensions: []
20
+ extra_rdoc_files:
21
+ - CHANGELOG.md
22
+ - README.md
23
+ - ext/sqlite3/aggregator.c
24
+ - ext/sqlite3/backup.c
25
+ - ext/sqlite3/database.c
26
+ - ext/sqlite3/exception.c
27
+ - ext/sqlite3/gvl.c
28
+ - ext/sqlite3/sqlite3.c
29
+ - ext/sqlite3/statement.c
30
+ files:
31
+ - ".gemtest"
32
+ - CHANGELOG.md
33
+ - CONTRIBUTING.md
34
+ - FAQ.md
35
+ - INSTALLATION.md
36
+ - LICENSE
37
+ - README.md
38
+ - dependencies.yml
39
+ - ext/sqlite3/aggregator.c
40
+ - ext/sqlite3/aggregator.h
41
+ - ext/sqlite3/backup.c
42
+ - ext/sqlite3/backup.h
43
+ - ext/sqlite3/database.c
44
+ - ext/sqlite3/database.h
45
+ - ext/sqlite3/exception.c
46
+ - ext/sqlite3/exception.h
47
+ - ext/sqlite3/extconf.rb
48
+ - ext/sqlite3/gvl.c
49
+ - ext/sqlite3/gvl.h
50
+ - ext/sqlite3/sqlite3.c
51
+ - ext/sqlite3/sqlite3_ruby.h
52
+ - ext/sqlite3/statement.c
53
+ - ext/sqlite3/statement.h
54
+ - ext/sqlite3/timespec.h
55
+ - lib/sqlite3.rb
56
+ - lib/sqlite3/3.2/sqlite3_native.so
57
+ - lib/sqlite3/3.3/sqlite3_native.so
58
+ - lib/sqlite3/3.4/sqlite3_native.so
59
+ - lib/sqlite3/4.0/sqlite3_native.so
60
+ - lib/sqlite3/cli.rb
61
+ - lib/sqlite3/constants.rb
62
+ - lib/sqlite3/database.rb
63
+ - lib/sqlite3/errors.rb
64
+ - lib/sqlite3/fork_safety.rb
65
+ - lib/sqlite3/pragmas.rb
66
+ - lib/sqlite3/resultset.rb
67
+ - lib/sqlite3/statement.rb
68
+ - lib/sqlite3/value.rb
69
+ - lib/sqlite3/version.rb
70
+ - lib/sqlite3/version_info.rb
71
+ - ports/aarch64-linux-gnu/sqlite3/3.53.2/bin/sqlite3
72
+ homepage: https://github.com/AccountAim/sqlite3-ruby
73
+ licenses:
74
+ - BSD-3-Clause
75
+ metadata:
76
+ homepage_uri: https://github.com/AccountAim/sqlite3-ruby
77
+ bug_tracker_uri: https://github.com/AccountAim/sqlite3-ruby/issues
78
+ documentation_uri: https://sparklemotion.github.io/sqlite3-ruby/
79
+ changelog_uri: https://github.com/sparklemotion/sqlite3-ruby/blob/master/CHANGELOG.md
80
+ source_code_uri: https://github.com/AccountAim/sqlite3-ruby
81
+ rubygems_mfa_required: 'true'
82
+ rdoc_options:
83
+ - "--main"
84
+ - README.md
85
+ require_paths:
86
+ - lib
87
+ required_ruby_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: '3.2'
92
+ - - "<"
93
+ - !ruby/object:Gem::Version
94
+ version: 4.1.dev
95
+ required_rubygems_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: 3.3.22
100
+ requirements: []
101
+ rubygems_version: 4.0.6
102
+ specification_version: 4
103
+ summary: AccountAim fork of the sqlite3 gem. Ruby library to interface with the SQLite3
104
+ database engine (http://www.sqlite.org).
105
+ test_files: []