patriot-sqlite3-client 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/init.rb +2 -0
- data/lib/patriot/util/db_client/sqlite3_client.rb +68 -0
- metadata +75 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
YzZhMWIzM2ZiYjYzZTg1NjA2ZTFhNTQzODVhZmFiMTVmNjNhYWQ3YQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
N2UyNTVmZGFlOGNkY2Q5ZTI1YTk4ZGRlNDYxMTJiZjRkZTZlZjlhMw==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
MDFmZTU1OTMyOTEzZjc4MWQ0NWY0ZGE3ZmU5Njg0ZDdlYzQ3YmU4ZWE3NmQ2
|
10
|
+
MDBjYWRiZTVlNDhjNTJkYzIyMzQ3NTllZTgyNDY5YTRjNGE1NzZjMGQzNDUx
|
11
|
+
ZGNkYWZhNTJkZmZiZmU0YmY2NTRlMzcxNWM3ZTVkNTUyZmIzOGY=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
NTc4MzEzNDQ4NWQ0NTlkYTIxMDdmYWI2YWNjZjcyNDcwZDcyNTYxOTczZjQ5
|
14
|
+
NjJiZWM1YTg2YTNjOGU2ZmYxOTI4NjgyMzczMGJlMWMyYmYzNDI5ZmRjMjJk
|
15
|
+
ZDA2NDM5MDIwZTgwZTBkYmE1ZDhjMDIxNjg5OTE1M2Q4NzIwNGU=
|
data/init.rb
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'sqlite3'
|
2
|
+
module Patriot
|
3
|
+
module Util
|
4
|
+
module DBClient
|
5
|
+
# get an sqlite3 client
|
6
|
+
# @param dbconf [Hash] dbclient configuration
|
7
|
+
def sqlite3(dbconf = {})
|
8
|
+
return Patriot::Util::DBClient::SQLite3Client.new(dbconf)
|
9
|
+
end
|
10
|
+
|
11
|
+
# NOT thread safe
|
12
|
+
class SQLite3Client < Patriot::Util::DBClient::Base
|
13
|
+
|
14
|
+
# @param dbconf [Hash] dbclient configuration
|
15
|
+
def initialize(dbconf)
|
16
|
+
db = dbconf[:database]
|
17
|
+
db = File.join($home, db) unless db.start_with?("/")
|
18
|
+
@connection = SQLite3::Database.new(dbconf[:database], :results_as_hash => true)
|
19
|
+
end
|
20
|
+
|
21
|
+
# @see Patriot::Util::DBClient::Base#do_select
|
22
|
+
def do_select(query)
|
23
|
+
return @connection.execute(query).map{|r| HashRecord.new(r)}
|
24
|
+
end
|
25
|
+
|
26
|
+
# @see Patriot::Util::DBClient::Base#build_insert_query
|
27
|
+
def build_insert_query(tbl, value, option = {})
|
28
|
+
option = {:ignore => false}.merge(option)
|
29
|
+
cols, vals = [], []
|
30
|
+
value.each do |c,v|
|
31
|
+
cols << c
|
32
|
+
vals << quote(v)
|
33
|
+
end
|
34
|
+
if option[:ignore]
|
35
|
+
return "INSERT OR IGNORE INTO #{tbl} (#{cols.join(',')}) VALUES (#{vals.join(',')})"
|
36
|
+
else
|
37
|
+
return "INSERT INTO #{tbl} (#{cols.join(',')}) VALUES (#{vals.join(',')})"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
# @see Patriot::Util::DBClient::Base#do_insert
|
42
|
+
def do_insert(query)
|
43
|
+
@connection.execute(query)
|
44
|
+
return @connection.last_insert_row_id
|
45
|
+
end
|
46
|
+
|
47
|
+
# @see Patriot::Util::DBClient::Base#do_update
|
48
|
+
def do_update(query)
|
49
|
+
@connection.execute(query)
|
50
|
+
return @connection.changes
|
51
|
+
end
|
52
|
+
|
53
|
+
# @see Patriot::Util::DBClient::Base#do_close
|
54
|
+
def close()
|
55
|
+
@connection.close unless @connection.nil?
|
56
|
+
end
|
57
|
+
|
58
|
+
# @see Patriot::Util::DBClient::Base#quote
|
59
|
+
def quote(v)
|
60
|
+
return 'NULL' if v.nil?
|
61
|
+
return "'#{v.to_s}'" if v.is_a?(DateTime)
|
62
|
+
return (v.is_a?(String) ? "'#{v.gsub(/'/,"''")}'" : v)
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
metadata
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: patriot-sqlite3-client
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.6.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Teruyoshi Zenmyo
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-06-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: sqlite3
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: patriot-workflow-scheduler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.6'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.6'
|
41
|
+
description: A dbadapter implementation to use sqlite3 as jobstore
|
42
|
+
email:
|
43
|
+
- zenmyo_teruyoshi@cyberagent.co.jp
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- init.rb
|
49
|
+
- lib/patriot/util/db_client/sqlite3_client.rb
|
50
|
+
homepage: https://github.com/CyberAgent/patriot-workflow-scheduler
|
51
|
+
licenses:
|
52
|
+
- Apache License, Version 2.0
|
53
|
+
metadata: {}
|
54
|
+
post_install_message:
|
55
|
+
rdoc_options: []
|
56
|
+
require_paths:
|
57
|
+
- lib
|
58
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ! '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ! '>='
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
requirements: []
|
69
|
+
rubyforge_project: patriot-sqlite3-client
|
70
|
+
rubygems_version: 2.4.7
|
71
|
+
signing_key:
|
72
|
+
specification_version: 4
|
73
|
+
summary: SQLite3 Client for Patriot Workflow Scheduler
|
74
|
+
test_files: []
|
75
|
+
has_rdoc:
|