activerecord-amazon-timestream-adapter 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/active_record/connection_adapters/amazon_timestream/database_statements.rb +2 -2
- data/lib/active_record/connection_adapters/amazon_timestream/quoting.rb +1 -1
- data/lib/active_record/connection_adapters/amazon_timestream/schema_statements.rb +4 -7
- data/lib/active_record/connection_adapters/amazon_timestream_adapter.rb +7 -20
- metadata +2 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 40439344b1bf48a7fa48d5870fe9dc26d8d1b3d6cf26de59e74356142caec035
|
4
|
+
data.tar.gz: 99fd64958f63efc61c9fd473639059b1c3394e7509fb3616d6caa84d14a192bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7bb934253342e57663de04d9fb2237852893676c218b48446fc052609676202c6ec6e6baa4e161fe24845989f036927ba4641292adb0e79da91466cb6abb8c27
|
7
|
+
data.tar.gz: 6d118754cdccdd5721c92f656819adde144a2a69f7068ec62ef1c253cbc7b21594d112d186ab9efa6b38b9f94bdb26796e86478e7c491558221c2cf713f1f291
|
@@ -8,7 +8,7 @@ module ActiveRecord
|
|
8
8
|
module DatabaseStatements
|
9
9
|
def execute(sql, name = nil)
|
10
10
|
log(sql, name) do
|
11
|
-
@
|
11
|
+
@connection.query({ query_string: sql })
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
@@ -18,7 +18,7 @@ module ActiveRecord
|
|
18
18
|
|
19
19
|
def exec_query(sql, name = 'SQL', binds = [])
|
20
20
|
log(sql, name, binds) do
|
21
|
-
response = @
|
21
|
+
response = @connection.query query_string: sql
|
22
22
|
|
23
23
|
ActiveRecord::Result.new response.column_info.map(&:name),
|
24
24
|
response.rows.map { |r| r.data.map(&:scalar_value) },
|
@@ -7,16 +7,13 @@ module ActiveRecord
|
|
7
7
|
module AmazonTimestream
|
8
8
|
module SchemaStatements
|
9
9
|
def tables(_name = nil)
|
10
|
-
response = @
|
11
|
-
|
12
|
-
response.tables.map(&:table_name)
|
10
|
+
response = @connection.query({ query_string: "SHOW TABLES FROM \"#{@database}\"" })
|
11
|
+
response.rows.map { |r| r.data[0].scalar_value }
|
13
12
|
end
|
14
13
|
|
15
14
|
def columns(table_name, _name = nil)
|
16
|
-
response = @
|
17
|
-
response.
|
18
|
-
Column.new(column.name, nil, lookup_cast_type(column.type.scalar_type))
|
19
|
-
end
|
15
|
+
response = @connection.query({ query_string: "DESCRIBE \"#{@database}\".\"#{table_name}\"" })
|
16
|
+
response.rows.map { |r| Column.new(r.data[0].scalar_value, nil, lookup_cast_type(r.data[1].scalar_value)) }
|
20
17
|
end
|
21
18
|
|
22
19
|
def table_exists?(_table_name)
|
@@ -7,7 +7,6 @@ require 'active_record/connection_adapters/amazon_timestream/schema_statements'
|
|
7
7
|
require 'arel/visitors/amazon_timestream'
|
8
8
|
require 'aws-sdk-core'
|
9
9
|
require 'aws-sdk-timestreamquery'
|
10
|
-
require 'aws-sdk-timestreamwrite'
|
11
10
|
|
12
11
|
module ActiveRecord
|
13
12
|
class Base
|
@@ -16,7 +15,10 @@ module ActiveRecord
|
|
16
15
|
|
17
16
|
raise ArgumentError, 'No database specified. Missing argument: database.' unless config.key?(:database)
|
18
17
|
|
19
|
-
|
18
|
+
credentials = Aws::Credentials.new config[:username], config[:password] if config[:username] && config[:password]
|
19
|
+
connection = Aws::TimestreamQuery::Client.new credentials: credentials
|
20
|
+
|
21
|
+
ConnectionAdapters::AmazonTimestreamAdapter.new(connection, logger, config[:database])
|
20
22
|
end
|
21
23
|
end
|
22
24
|
|
@@ -28,11 +30,10 @@ module ActiveRecord
|
|
28
30
|
include AmazonTimestream::DatabaseStatements
|
29
31
|
include AmazonTimestream::Quoting
|
30
32
|
|
31
|
-
def initialize(logger,
|
32
|
-
super(
|
33
|
-
@
|
33
|
+
def initialize(connection, logger, database)
|
34
|
+
super(connection, logger)
|
35
|
+
@database = database
|
34
36
|
@visitor = Arel::Visitors::AmazonTimestream.new self
|
35
|
-
connect!
|
36
37
|
end
|
37
38
|
|
38
39
|
def supports_explain?
|
@@ -44,10 +45,7 @@ module ActiveRecord
|
|
44
45
|
end
|
45
46
|
|
46
47
|
def active?
|
47
|
-
@query.query({ query_string: 'SELECT 1' })
|
48
48
|
true
|
49
|
-
rescue StandardError
|
50
|
-
false
|
51
49
|
end
|
52
50
|
|
53
51
|
protected
|
@@ -63,17 +61,6 @@ module ActiveRecord
|
|
63
61
|
|
64
62
|
mapping.alias_type(/unknown/i, 'varchar')
|
65
63
|
end
|
66
|
-
|
67
|
-
private
|
68
|
-
|
69
|
-
def connect!
|
70
|
-
if @config[:username] && @config[:password]
|
71
|
-
credentials = Aws::Credentials.new(@config[:username], @config[:password])
|
72
|
-
end
|
73
|
-
|
74
|
-
@query = Aws::TimestreamQuery::Client.new credentials: credentials
|
75
|
-
@write = Aws::TimestreamWrite::Client.new credentials: credentials
|
76
|
-
end
|
77
64
|
end
|
78
65
|
end
|
79
66
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-amazon-timestream-adapter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Francois Deschenes
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-11-
|
11
|
+
date: 2020-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -80,20 +80,6 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '1.0'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: aws-sdk-timestreamwrite
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - "~>"
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '1.0'
|
90
|
-
type: :runtime
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - "~>"
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '1.0'
|
97
83
|
description:
|
98
84
|
email: fdeschenes@me.com
|
99
85
|
executables: []
|