sqlite3 0.0.5 → 0.0.6

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.5
1
+ 0.0.6
@@ -1,14 +1,6 @@
1
1
  module SQLite3
2
2
  module Constants
3
3
 
4
- # module TextRep
5
- # UTF8 = 1
6
- # UTF16LE = 2
7
- # UTF16BE = 3
8
- # UTF16 = 4
9
- # ANY = 5
10
- # end
11
-
12
4
  module ColumnType
13
5
  INTEGER = 1
14
6
  FLOAT = 2
@@ -77,9 +77,6 @@ module SQLite3
77
77
 
78
78
  @closed = false
79
79
  @results_as_hash = options.fetch(:results_as_hash, false)
80
- # @type_translation = options.fetch(:type_translation, false)
81
- # @translator = nil
82
- # @transaction_active = false
83
80
  end
84
81
 
85
82
  # Return +true+ if the string is a valid (ie, parsable) SQL statement, and
@@ -100,16 +97,6 @@ module SQLite3
100
97
  @driver.errcode(@handle)
101
98
  end
102
99
 
103
- # Return the type translator employed by this database instance. Each
104
- # database instance has its own type translator; this allows for different
105
- # type handlers to be installed in each instance without affecting other
106
- # instances. Furthermore, the translators are instantiated lazily, so that
107
- # if a database does not use type translation, it will not be burdened by
108
- # the overhead of a useless type translator. (See the Translator class.)
109
- # def translator
110
- # @translator ||= Translator.new
111
- # end
112
-
113
100
  # Closes this database.
114
101
  def close
115
102
  unless @closed
@@ -189,49 +176,6 @@ module SQLite3
189
176
  end
190
177
  end
191
178
 
192
- # Executes all SQL statements in the given string. By contrast, the other
193
- # means of executing queries will only execute the first statement in the
194
- # string, ignoring all subsequent statements. This will execute each one
195
- # in turn. The same bind parameters, if given, will be applied to each
196
- # statement.
197
- #
198
- # This always returns +nil+, making it unsuitable for queries that return
199
- # rows.
200
- # def execute_batch(sql, *bind_vars)
201
- # sql = sql.strip
202
- # until sql.empty? do
203
- # prepare(sql) do |stmt|
204
- # stmt.execute(*bind_vars)
205
- # sql = stmt.remainder.strip
206
- # end
207
- # end
208
- # nil
209
- # end
210
-
211
- # This is a convenience method for creating a statement, binding
212
- # paramters to it, and calling execute:
213
- #
214
- # result = db.query("select * from foo where a=?", 5)
215
- # # is the same as
216
- # result = db.prepare("select * from foo where a=?").execute(5)
217
- #
218
- # You must be sure to call +close+ on the ResultSet instance that is
219
- # returned, or you could have problems with locks on the table. If called
220
- # with a block, +close+ will be invoked implicitly when the block
221
- # terminates.
222
- # def query(sql, *bind_vars)
223
- # result = prepare(sql).execute(*bind_vars)
224
- # if block_given?
225
- # begin
226
- # yield result
227
- # ensure
228
- # result.close
229
- # end
230
- # else
231
- # return result
232
- # end
233
- # end
234
-
235
179
  # A convenience method for obtaining the first row of a result set, and
236
180
  # discarding all others. It is otherwise identical to #execute.
237
181
  #
@@ -264,17 +208,6 @@ module SQLite3
264
208
  @driver.changes(@handle)
265
209
  end
266
210
 
267
- # Returns the total number of changes made to this database instance
268
- # since it was opened.
269
- # def total_changes
270
- # @driver.total_changes(@handle)
271
- # end
272
-
273
- # Interrupts the currently executing operation, causing it to abort.
274
- # def interrupt
275
- # @driver.interrupt(@handle)
276
- # end
277
-
278
211
  # Indicates that if a request for a resource terminates because that
279
212
  # resource is busy, SQLite should sleep and retry for up to the indicated
280
213
  # number of milliseconds. By default, SQLite does not retry
@@ -377,4 +310,3 @@ module SQLite3
377
310
 
378
311
  end
379
312
  end
380
-
@@ -11,7 +11,7 @@ module SQLite3
11
11
  "libsqlite3.dylib"
12
12
  when /linux|freebsd|netbsd|openbsd|dragonfly|solaris/
13
13
  "libsqlite3.so"
14
- when /win32|i386-mingw32/
14
+ when /win|mingw/
15
15
  "sqlite3.dll"
16
16
  else
17
17
  abort <<-EOF
@@ -33,16 +33,10 @@ EOF
33
33
  attach_function :sqlite3_errmsg16, [:pointer], :pointer
34
34
  attach_function :sqlite3_errcode, [:pointer], :int
35
35
  attach_function :sqlite3_prepare, [:pointer, :string, :int, :pointer, :pointer], :int
36
- # attach_function :sqlite3_prepare16, [:pointer, :pointer, :int, :pointer, :pointer], :int
37
36
  attach_function :sqlite3_finalize, [:pointer], :int
38
- # attach_function :sqlite3_reset, [:pointer], :int
39
37
  attach_function :sqlite3_step, [:pointer], :int
40
38
  attach_function :sqlite3_last_insert_rowid, [:pointer], :int64
41
39
  attach_function :sqlite3_changes, [:pointer], :int
42
- # attach_function :sqlite3_total_changes, [:pointer], :int
43
- # attach_function :sqlite3_interrupt, [:pointer], :void
44
- # attach_function :sqlite3_complete, [:string], :int
45
- # attach_function :sqlite3_complete16, [:pointer], :int
46
40
  attach_function :sqlite3_busy_timeout, [:pointer, :int], :int
47
41
  attach_function :sqlite3_bind_blob, [:pointer, :int, :pointer, :int, :pointer], :int
48
42
  attach_function :sqlite3_bind_double, [:pointer, :int, :double], :int
@@ -51,57 +45,18 @@ EOF
51
45
  attach_function :sqlite3_bind_null, [:pointer, :int], :int
52
46
  attach_function :sqlite3_bind_text, [:pointer, :int, :string, :int, :pointer], :int
53
47
  attach_function :sqlite3_bind_text16, [:pointer, :int, :pointer, :int, :pointer], :int
54
- # attach_function :sqlite3_bind_value, [:pointer, :int, :pointer], :int
55
- # attach_function :sqlite3_bind_parameter_count, [:pointer], :int
56
- # attach_function :sqlite3_bind_parameter_name, [:pointer, :int], :string
57
- # attach_function :sqlite3_bind_parameter_index, [:pointer, :string], :int
58
48
  attach_function :sqlite3_column_count, [:pointer], :int
59
49
  attach_function :sqlite3_data_count, [:pointer], :int
60
50
  attach_function :sqlite3_column_blob, [:pointer, :int], :pointer
61
51
  attach_function :sqlite3_column_bytes, [:pointer, :int], :int
62
52
  attach_function :sqlite3_column_bytes16, [:pointer, :int], :int
63
53
  attach_function :sqlite3_column_decltype, [:pointer, :int], :string
64
- # attach_function :sqlite3_column_decltype16, [:pointer, :int], :pointer
65
54
  attach_function :sqlite3_column_double, [:pointer, :int], :double
66
- # attach_function :sqlite3_column_int, [:pointer, :int], :int
67
55
  attach_function :sqlite3_column_int64, [:pointer, :int], :int64
68
56
  attach_function :sqlite3_column_name, [:pointer, :int], :string
69
- # attach_function :sqlite3_column_name16, [:pointer, :int], :pointer
70
57
  attach_function :sqlite3_column_text, [:pointer, :int], :string
71
58
  attach_function :sqlite3_column_text16, [:pointer, :int], :pointer
72
59
  attach_function :sqlite3_column_type, [:pointer, :int], :int
73
- # attach_function :sqlite3_aggregate_count, [:pointer], :int
74
- # attach_function :sqlite3_value_blob, [:pointer], :pointer
75
- # attach_function :sqlite3_value_bytes, [:pointer], :int
76
- # attach_function :sqlite3_value_bytes16, [:pointer], :int
77
- # attach_function :sqlite3_value_double, [:pointer], :double
78
- # attach_function :sqlite3_value_int, [:pointer], :int
79
- # attach_function :sqlite3_value_int64, [:pointer], :int64
80
- # attach_function :sqlite3_value_text, [:pointer], :string
81
- # attach_function :sqlite3_value_text16, [:pointer], :pointer
82
- # attach_function :sqlite3_value_text16le, [:pointer], :pointer
83
- # attach_function :sqlite3_value_text16be, [:pointer], :pointer
84
- # attach_function :sqlite3_value_type, [:pointer], :int
85
- # attach_function :sqlite3_aggregate_context, [:pointer, :int], :pointer
86
- # attach_function :sqlite3_user_data, [:pointer], :pointer
87
- # attach_function :sqlite3_get_auxdata, [:pointer, :int], :pointer
88
- # attach_function :sqlite3_set_auxdata, [:pointer, :int, :pointer, :pointer], :void
89
- # attach_function :sqlite3_result_blob, [:pointer, :pointer, :int, :pointer], :void
90
- # attach_function :sqlite3_result_double, [:pointer, :double], :void
91
- # attach_function :sqlite3_result_error, [:pointer, :string, :int], :void
92
- # attach_function :sqlite3_result_error16, [:pointer, :pointer, :int], :void
93
- # attach_function :sqlite3_result_int, [:pointer, :int], :void
94
- # attach_function :sqlite3_result_int64, [:pointer, :int64], :void
95
- # attach_function :sqlite3_result_null, [:pointer], :void
96
- # attach_function :sqlite3_result_text, [:pointer, :string, :int, :pointer], :void
97
- # attach_function :sqlite3_result_text16, [:pointer, :pointer, :int, :pointer], :void
98
- # attach_function :sqlite3_result_text16le, [:pointer, :pointer, :int, :pointer], :void
99
- # attach_function :sqlite3_result_text16be, [:pointer, :pointer, :int, :pointer], :void
100
- # attach_function :sqlite3_result_value, [:pointer, :pointer], :void
101
- # attach_function :sqlite3_create_collation, [:pointer, :string, :int, :pointer, :pointer], :int
102
- # attach_function :sqlite3_create_collation16, [:pointer, :string, :int, :pointer, :pointer], :int
103
- # attach_function :sqlite3_collation_needed, [:pointer, :pointer, :pointer], :int
104
- # attach_function :sqlite3_collation_needed16, [:pointer, :pointer, :pointer], :int
105
60
  end
106
61
 
107
62
  end
@@ -44,66 +44,6 @@ module SQLite3
44
44
  [result, handle.get_pointer(0), remainder_string]
45
45
  end
46
46
 
47
- # def complete?(sql)
48
- # API.send(utf16?(string) ? :sqlite3_complete16 : :sqlite3_complete, sql)
49
- # end
50
-
51
- # def value_blob(value)
52
- # blob = API.sqlite3_value_blob(value)
53
- # # blob.free = nil
54
- # blob.to_s(API.sqlite3_value_bytes(value))
55
- # end
56
-
57
- # def value_text(value)
58
- # method = case utf16
59
- # when nil, false
60
- # :sqlite3_value_text
61
- # when :le
62
- # :sqlite3_value_text16le
63
- # when :be
64
- # :sqlite3_value_text16be
65
- # else
66
- # :sqlite3_value_text16
67
- # end
68
-
69
- # result = API.send(method, value)
70
-
71
- # if utf16
72
- # # result.free = nil
73
- # size = API.sqlite3_value_bytes(value)
74
- # result = result.to_s(size)
75
- # end
76
-
77
- # result
78
- # end
79
-
80
- # def result_text(func, text)
81
- # method = case utf16
82
- # when false, nil
83
- # :sqlite3_result_text
84
- # when :le
85
- # :sqlite3_result_text16le
86
- # when :be
87
- # :sqlite3_result_text16be
88
- # else
89
- # :sqlite3_result_text16
90
- # end
91
-
92
- # s = text.to_s
93
- # API.send(method, func, s, s.length, TRANSIENT)
94
- # end
95
-
96
- # def aggregate_context(context)
97
- # ptr = API.sqlite3_aggregate_context(context, 4)
98
- # ptr.free = nil
99
- # obj = (ptr ? ptr.to_object : nil)
100
- # if obj.nil?
101
- # obj = Hash.new
102
- # ptr.set_object obj
103
- # end
104
- # obj
105
- # end
106
-
107
47
  def bind_string(stmt, index, value)
108
48
  case value.encoding
109
49
  when Encoding.utf_8, Encoding.us_ascii
@@ -138,7 +78,6 @@ module SQLite3
138
78
 
139
79
  api_delegate :column_name
140
80
  api_delegate :column_decltype
141
- # api_delegate :aggregate_count
142
81
  api_delegate :bind_double
143
82
  api_delegate :bind_int
144
83
  api_delegate :bind_int64
@@ -148,29 +87,16 @@ module SQLite3
148
87
  api_delegate :busy_timeout
149
88
  api_delegate :changes
150
89
  api_delegate :close
151
- # api_delegate :column_bytes
152
- # api_delegate :column_bytes16
153
90
  api_delegate :column_count
154
91
  api_delegate :column_double
155
- # api_delegate :column_int
156
92
  api_delegate :column_int64
157
93
  api_delegate :column_type
158
94
  api_delegate :data_count
159
95
  api_delegate :errcode
160
96
  api_delegate :finalize
161
- # api_delegate :interrupt
162
97
  api_delegate :last_insert_rowid
163
98
  api_delegate :libversion
164
- # api_delegate :reset
165
- # api_delegate :result_error
166
99
  api_delegate :step
167
- # api_delegate :total_changes
168
- # api_delegate :value_bytes
169
- # api_delegate :value_bytes16
170
- # api_delegate :value_double
171
- # api_delegate :value_int
172
- # api_delegate :value_int64
173
- # api_delegate :value_type
174
100
 
175
101
  private
176
102
 
@@ -41,17 +41,18 @@ module SQLite3
41
41
  class RangeException < Exception; end
42
42
  class NotADatabaseException < Exception; end
43
43
 
44
- EXCEPTIONS = [
45
- nil,
46
- SQLException, InternalException, PermissionException,
47
- AbortException, BusyException, LockedException, MemoryException,
48
- ReadOnlyException, InterruptException, IOException, CorruptException,
49
- NotFoundException, FullException, CantOpenException, ProtocolException,
50
- EmptyException, SchemaChangedException, TooBigException,
51
- ConstraintException, MismatchException, MisuseException,
52
- UnsupportedException, AuthorizationException, FormatException,
53
- RangeException, NotADatabaseException
54
- ].each_with_index { |e,i| e.instance_variable_set( :@code, i ) if e }
44
+ EXCEPTIONS =
45
+ [
46
+ nil, SQLException, InternalException,
47
+ PermissionException, AbortException, BusyException,
48
+ LockedException, MemoryException, ReadOnlyException,
49
+ InterruptException, IOException, CorruptException,
50
+ NotFoundException, FullException, CantOpenException,
51
+ ProtocolException, EmptyException, SchemaChangedException,
52
+ TooBigException, ConstraintException, MismatchException,
53
+ MisuseException, UnsupportedException, AuthorizationException,
54
+ FormatException, RangeException, NotADatabaseException
55
+ ].each_with_index { |e,i| e.instance_variable_set(:@code, i ) if e }
55
56
 
56
57
  module Error
57
58
  def check( result, db=nil, msg=nil )
@@ -7,211 +7,6 @@ module SQLite3
7
7
  # at http://sqlite.org/pragma.html.
8
8
  module Pragmas
9
9
 
10
- # Returns +true+ or +false+ depending on the value of the named pragma.
11
- # def get_boolean_pragma(name)
12
- # get_first_value("PRAGMA #{name}") != "0"
13
- # end
14
- # private :get_boolean_pragma
15
-
16
- # Sets the given pragma to the given boolean value. The value itself
17
- # may be +true+ or +false+, or any other commonly used string or
18
- # integer that represents truth.
19
- # def set_boolean_pragma(name, mode)
20
- # case mode
21
- # when String
22
- # case mode.downcase
23
- # when "on", "yes", "true", "y", "t"
24
- # mode = "'ON'"
25
- # when "off", "no", "false", "n", "f"
26
- # mode = "'OFF'"
27
- # else
28
- # raise Exception, "unrecognized pragma parameter #{mode.inspect}"
29
- # end
30
- # when true, 1
31
- # mode = "ON"
32
- # when false, 0, nil
33
- # mode = "OFF"
34
- # else
35
- # raise Exception,
36
- # "unrecognized pragma parameter #{mode.inspect}"
37
- # end
38
-
39
- # execute("PRAGMA #{name}=#{mode}")
40
- # end
41
- # private :set_boolean_pragma
42
-
43
- # Requests the given pragma (and parameters), and if the block is given,
44
- # each row of the result set will be yielded to it. Otherwise, the results
45
- # are returned as an array.
46
- # def get_query_pragma(name, *parms, &block) # :yields: row
47
- # if parms.empty?
48
- # execute("PRAGMA #{name}", &block)
49
- # else
50
- # args = "'" + parms.join("','") + "'"
51
- # execute("PRAGMA #{name}(#{args})", &block)
52
- # end
53
- # end
54
- # private :get_query_pragma
55
-
56
- # Return the value of the given pragma.
57
- # def get_enum_pragma(name)
58
- # get_first_value("PRAGMA #{name}")
59
- # end
60
- # private :get_enum_pragma
61
-
62
- # Set the value of the given pragma to +mode+. The +mode+ parameter must
63
- # conform to one of the values in the given +enum+ array. Each entry in
64
- # the array is another array comprised of elements in the enumeration that
65
- # have duplicate values. See #synchronous, #default_synchronous,
66
- # #temp_store, and #default_temp_store for usage examples.
67
- # def set_enum_pragma(name, mode, enums)
68
- # match = enums.find { |p| p.find { |i| i.to_s.downcase == mode.to_s.downcase } }
69
- # raise Exception,
70
- # "unrecognized #{name} #{mode.inspect}" unless match
71
- # execute("PRAGMA #{name}='#{match.first.upcase}'")
72
- # end
73
- # private :set_enum_pragma
74
-
75
- # Returns the value of the given pragma as an integer.
76
- # def get_int_pragma(name)
77
- # get_first_value("PRAGMA #{name}").to_i
78
- # end
79
- # private :get_int_pragma
80
-
81
- # Set the value of the given pragma to the integer value of the +value+
82
- # parameter.
83
- # def set_int_pragma(name, value)
84
- # execute("PRAGMA #{name}=#{value.to_i}")
85
- # end
86
- # private :set_int_pragma
87
-
88
- # The enumeration of valid synchronous modes.
89
- # SYNCHRONOUS_MODES = [ [ "full", 2 ], [ "normal", 1 ], [ "off", 0 ] ]
90
-
91
- # The enumeration of valid temp store modes.
92
- # TEMP_STORE_MODES = [ [ "default", 0 ], [ "file", 1 ], [ "memory", 2 ] ]
93
-
94
- # Does an integrity check on the database. If the check fails, a
95
- # SQLite3::Exception will be raised. Otherwise it
96
- # returns silently.
97
- # def integrity_check
98
- # execute("PRAGMA integrity_check") do |row|
99
- # raise Exception, row[0] if row[0] != "ok"
100
- # end
101
- # end
102
-
103
- # def auto_vacuum
104
- # get_boolean_pragma "auto_vacuum"
105
- # end
106
-
107
- # def auto_vacuum=(mode)
108
- # set_boolean_pragma "auto_vacuum", mode
109
- # end
110
-
111
- # def schema_cookie
112
- # get_int_pragma "schema_cookie"
113
- # end
114
-
115
- # def schema_cookie=(cookie)
116
- # set_int_pragma "schema_cookie", cookie
117
- # end
118
-
119
- # def user_cookie
120
- # get_int_pragma "user_cookie"
121
- # end
122
-
123
- # def user_cookie=(cookie)
124
- # set_int_pragma "user_cookie", cookie
125
- # end
126
-
127
- # def cache_size
128
- # get_int_pragma "cache_size"
129
- # end
130
-
131
- # def cache_size=(size)
132
- # set_int_pragma "cache_size", size
133
- # end
134
-
135
- # def default_cache_size
136
- # get_int_pragma "default_cache_size"
137
- # end
138
-
139
- # def default_cache_size=(size)
140
- # set_int_pragma "default_cache_size", size
141
- # end
142
-
143
- # def default_synchronous
144
- # get_enum_pragma "default_synchronous"
145
- # end
146
-
147
- # def default_synchronous=(mode)
148
- # set_enum_pragma "default_synchronous", mode, SYNCHRONOUS_MODES
149
- # end
150
-
151
- # def synchronous
152
- # get_enum_pragma "synchronous"
153
- # end
154
-
155
- # def synchronous=(mode)
156
- # set_enum_pragma "synchronous", mode, SYNCHRONOUS_MODES
157
- # end
158
-
159
- # def default_temp_store
160
- # get_enum_pragma "default_temp_store"
161
- # end
162
-
163
- # def default_temp_store=(mode)
164
- # set_enum_pragma "default_temp_store", mode, TEMP_STORE_MODES
165
- # end
166
-
167
- # def temp_store
168
- # get_enum_pragma "temp_store"
169
- # end
170
-
171
- # def temp_store=(mode)
172
- # set_enum_pragma "temp_store", mode, TEMP_STORE_MODES
173
- # end
174
-
175
- # def full_column_names
176
- # get_boolean_pragma "full_column_names"
177
- # end
178
-
179
- # def full_column_names=(mode)
180
- # set_boolean_pragma "full_column_names", mode
181
- # end
182
-
183
- # def parser_trace
184
- # get_boolean_pragma "parser_trace"
185
- # end
186
-
187
- # def parser_trace=(mode)
188
- # set_boolean_pragma "parser_trace", mode
189
- # end
190
-
191
- # def vdbe_trace
192
- # get_boolean_pragma "vdbe_trace"
193
- # end
194
-
195
- # def vdbe_trace=(mode)
196
- # set_boolean_pragma "vdbe_trace", mode
197
- # end
198
-
199
- # def database_list(&block) # :yields: row
200
- # get_query_pragma "database_list", &block
201
- # end
202
-
203
- # def foreign_key_list(table, &block) # :yields: row
204
- # get_query_pragma "foreign_key_list", table, &block
205
- # end
206
-
207
- # def index_info(index, &block) # :yields: row
208
- # get_query_pragma "index_info", index, &block
209
- # end
210
-
211
- # def index_list(table, &block) # :yields: row
212
- # get_query_pragma "index_list", table, &block
213
- # end
214
-
215
10
  def table_info(table, &block) # :yields: row
216
11
  columns, *rows = execute2("PRAGMA table_info(#{table})")
217
12
 
@@ -198,9 +198,6 @@ module SQLite3
198
198
  @columns << @driver.column_name(@handle, column)
199
199
  @types << @driver.column_decltype(@handle, column)
200
200
  end
201
-
202
- @columns.freeze
203
- @types.freeze
204
201
  end
205
202
  private :get_metadata
206
203
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sqlite3
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Jakub Ku\xC5\xBAma"
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-20 00:00:00 +01:00
12
+ date: 2009-12-26 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency