recordx_sqlite 0.2.8 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4b44048b009559164329691d2a4d51e3c99d189661e0573d5c085bf07b4853d0
4
- data.tar.gz: 80a3444ce15b8336756e9c9e7ef9c883270524d04cbda56449ccdecb81a6ba53
3
+ metadata.gz: aac342f113f858c93a70cc2333e34bb84d5f91b7910d344241d914b0a3bd7e01
4
+ data.tar.gz: 13da368af4262865562e33b44efbd45217a634a6f89db31648b0cf6f03b726b6
5
5
  SHA512:
6
- metadata.gz: 7537ab7d8001b944a8c1df38e4125e4d7fdc039fb857dee6ec0825f7af941d3de5e751683c5e7204b18c19afbe8234d63d53a5248cfb666fde544e8eb2073c2a
7
- data.tar.gz: 4d559fb3701f741870ce138ed7bd3711e09cb808659cda5b1125ae3b56117d288130b320d078efa1a534fb12fa58817cb16fac6a10673c02d185a1c637995d84
6
+ metadata.gz: 1c00a97da8f06749aac53a458685cccfee3a72c7ab629c6abdacdc5c07ce0cf77c3bda8b23c1e2cc6fbb9b2e3c95349d445510ac79f5c6c9e3bf929630b21cfc
7
+ data.tar.gz: 59d0707c7f804dbefbc8ca564f4cc375c9dd2349870c2eddc5f4579a919e93f021215e45ecfdb28b8acd19921b7e4c8708c190bb26e4afd2cea7b9441e121c72
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -4,12 +4,13 @@
4
4
 
5
5
  require 'sqlite3'
6
6
  require 'recordx'
7
+ require 'drb_sqlite'
7
8
 
8
9
 
9
10
  class RecordxSqlite
10
11
 
11
- def initialize(dbfile, table: '', primary_key: :id, pk: primary_key,
12
- sql: nil, pagesize: 10, debug: true)
12
+ def initialize(dbfile, table: nil, primary_key: :id, pk: primary_key,
13
+ sql: nil, pagesize: 10, debug: false)
13
14
 
14
15
  @debug = debug
15
16
  sqlite = dbfile =~ /^sqlite:\/\// ? DRbSQLite : SQLite3::Database
@@ -28,6 +29,19 @@ class RecordxSqlite
28
29
  @primary_key = h[@table].keys.first
29
30
 
30
31
  create_table(@table, h[@table]) if @db.table_info(@table).empty?
32
+
33
+ else
34
+
35
+ if @db.respond_to? :tables then
36
+ @table = @db.tables.first
37
+ @primary_key = @db.fields(@table).first
38
+ else
39
+ sql = "SELECT name FROM sqlite_master WHERE type='table';"
40
+ a = @db.execute(sql).flat_map(&:to_a)
41
+ sys = a.grep /^sqlite_/
42
+ @table = (a - sys).first
43
+ @primary_key = @db.table_info(@table).map {|x| x['name'].to_sym }.first
44
+ end
31
45
 
32
46
  end
33
47
 
@@ -93,9 +107,20 @@ class RecordxSqlite
93
107
 
94
108
  end
95
109
 
96
- def query(sql=@sql, cache: true)
97
-
98
- rs = @db.query sql
110
+ def query(sql=@sql, cache: true, heading: true)
111
+
112
+ if heading then
113
+
114
+ rs = @db.query sql
115
+
116
+ else
117
+
118
+ @db.results_as_hash = false
119
+ rs = @db.query(sql).to_a
120
+ @db.results_as_hash = true
121
+
122
+ return rs
123
+ end
99
124
 
100
125
  a = rs.map do |h|
101
126
  h2 = h.inject({}) {|r, x| k, v = x; r.merge(k.to_sym => v)}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: recordx_sqlite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.8
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -35,7 +35,7 @@ cert_chain:
35
35
  kccsQ7sAxN8HjTTcD7MMTYpZFDz95j0Q2C4BqH0dRtYCO7bU44KuuniAs+5s9tP9
36
36
  QWFC3bomTAgC+DL5m062pKLU
37
37
  -----END CERTIFICATE-----
38
- date: 2019-02-20 00:00:00.000000000 Z
38
+ date: 2019-08-24 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: sqlite3
@@ -43,40 +43,60 @@ dependencies:
43
43
  requirements:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: '1.3'
46
+ version: '1.4'
47
47
  - - ">="
48
48
  - !ruby/object:Gem::Version
49
- version: 1.3.11
49
+ version: 1.4.1
50
50
  type: :runtime
51
51
  prerelease: false
52
52
  version_requirements: !ruby/object:Gem::Requirement
53
53
  requirements:
54
54
  - - "~>"
55
55
  - !ruby/object:Gem::Version
56
- version: '1.3'
56
+ version: '1.4'
57
57
  - - ">="
58
58
  - !ruby/object:Gem::Version
59
- version: 1.3.11
59
+ version: 1.4.1
60
60
  - !ruby/object:Gem::Dependency
61
61
  name: recordx
62
62
  requirement: !ruby/object:Gem::Requirement
63
63
  requirements:
64
- - - ">="
65
- - !ruby/object:Gem::Version
66
- version: 0.4.0
67
64
  - - "~>"
68
65
  - !ruby/object:Gem::Version
69
- version: '0.4'
66
+ version: '0.5'
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: 0.5.4
70
70
  type: :runtime
71
71
  prerelease: false
72
72
  version_requirements: !ruby/object:Gem::Requirement
73
73
  requirements:
74
+ - - "~>"
75
+ - !ruby/object:Gem::Version
76
+ version: '0.5'
74
77
  - - ">="
75
78
  - !ruby/object:Gem::Version
76
- version: 0.4.0
79
+ version: 0.5.4
80
+ - !ruby/object:Gem::Dependency
81
+ name: drb_sqlite
82
+ requirement: !ruby/object:Gem::Requirement
83
+ requirements:
77
84
  - - "~>"
78
85
  - !ruby/object:Gem::Version
79
- version: '0.4'
86
+ version: '0.3'
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: 0.3.3
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.3'
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: 0.3.3
80
100
  description:
81
101
  email: james@jamesrobertson.eu
82
102
  executables: []
metadata.gz.sig CHANGED
Binary file