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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/recordx_sqlite.rb +30 -5
- metadata +32 -12
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aac342f113f858c93a70cc2333e34bb84d5f91b7910d344241d914b0a3bd7e01
|
4
|
+
data.tar.gz: 13da368af4262865562e33b44efbd45217a634a6f89db31648b0cf6f03b726b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c00a97da8f06749aac53a458685cccfee3a72c7ab629c6abdacdc5c07ce0cf77c3bda8b23c1e2cc6fbb9b2e3c95349d445510ac79f5c6c9e3bf929630b21cfc
|
7
|
+
data.tar.gz: 59d0707c7f804dbefbc8ca564f4cc375c9dd2349870c2eddc5f4579a919e93f021215e45ecfdb28b8acd19921b7e4c8708c190bb26e4afd2cea7b9441e121c72
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/recordx_sqlite.rb
CHANGED
@@ -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:
|
12
|
-
sql: nil, pagesize: 10, debug:
|
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
|
-
|
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.
|
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-
|
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.
|
46
|
+
version: '1.4'
|
47
47
|
- - ">="
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version: 1.
|
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.
|
56
|
+
version: '1.4'
|
57
57
|
- - ">="
|
58
58
|
- !ruby/object:Gem::Version
|
59
|
-
version: 1.
|
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.
|
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
|
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.
|
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
|