activerecord-dsql-adapter 0.1.0
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.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +0 -0
- data/README.md +46 -0
- data/lib/active_record/connection_adapters/dsql_adapter.rb +61 -0
- data/lib/activerecord-dsql-adapter.rb +6 -0
- data.tar.gz.sig +0 -0
- metadata +110 -0
- metadata.gz.sig +0 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7d5653142d403dfb1efc8e710f3f2e9cc72264bfdce1f0a21e0fb7f8d4ee316f
|
4
|
+
data.tar.gz: f66eb457cedb77489ec8c761e022af67f9d68cac59cf6eb4db7c12851868592e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 56ebe63d14994b848c165eb8a95844d51c182eca011578694a183883e36f3c6ef9ee75f5c8a982d056144baf5ab4264e016ed64d52dcee16b0654fa7022cc16e
|
7
|
+
data.tar.gz: 1a81f168feff53852f0cc6c192e744f70dca091155ebdef87a92901104940d58a8568150560562998675dc745a62178d11eec513e6cb7aa48846dbbd015b935c
|
checksums.yaml.gz.sig
ADDED
Binary file
|
data/README.md
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# Active Record Adapter for AWS Aurora DSQL
|
2
|
+
|
3
|
+
The very beginnings of an Active Record connection adapter for Amazon's AWS Aurora DSQL database.
|
4
|
+
|
5
|
+
https://docs.aws.amazon.com/aurora-dsql/latest/userguide/
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
```
|
10
|
+
bundle add activerecord-dsql-adapter
|
11
|
+
```
|
12
|
+
|
13
|
+
## Usage
|
14
|
+
|
15
|
+
```
|
16
|
+
# config/database.yml
|
17
|
+
development:
|
18
|
+
adapter: dsql
|
19
|
+
host: abc123.dsql.us-east-1.on.aws
|
20
|
+
```
|
21
|
+
|
22
|
+
Credentials available in ENV or inside your `~/.aws/config` file will be used to generate an appropriate AWS signature as a password:
|
23
|
+
|
24
|
+
https://docs.aws.amazon.com/aurora-dsql/latest/userguide/authentication-token-ruby.html
|
25
|
+
|
26
|
+
```
|
27
|
+
$ rails console
|
28
|
+
Loading development environment (Rails 7.2.2)
|
29
|
+
|
30
|
+
dsql-example(dev)> ActiveRecord::Base.connection.raw_connection
|
31
|
+
#<PG::Connection:0x000000011dab5860 host=abc123.dsql.us-east-1.on.aws port=5432 user=admin>
|
32
|
+
|
33
|
+
dsql-example(dev)> ActiveRecord::Base.connection.execute("SELECT 1")
|
34
|
+
(1844.8ms) SELECT 1
|
35
|
+
=> #<PG::Result:0x00000001238b39a8 status=PGRES_TUPLES_OK ntuples=1 nfields=1 cmd_tuples=1>
|
36
|
+
```
|
37
|
+
|
38
|
+
## Development
|
39
|
+
|
40
|
+
After checking out the repo, run `script/setup` to install dependencies. You can also run `script/console` for an interactive prompt that will allow you to experiment.
|
41
|
+
|
42
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
43
|
+
|
44
|
+
## Contributing
|
45
|
+
|
46
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/sj26/activerecord-dsql-adapter.
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "aws-sdk-dsql"
|
4
|
+
|
5
|
+
require "active_record"
|
6
|
+
require "active_record/connection_adapters/postgresql_adapter"
|
7
|
+
|
8
|
+
module ActiveRecord
|
9
|
+
module ConnectionAdapters
|
10
|
+
class DSQLAdapter < PostgreSQLAdapter
|
11
|
+
ADAPTER_NAME = "DSQL"
|
12
|
+
|
13
|
+
class << self
|
14
|
+
def new_client(conn_params)
|
15
|
+
conn_params[:sslmode] ||= "require"
|
16
|
+
conn_params[:user] ||= "admin"
|
17
|
+
conn_params[:dbname] ||= "postgres"
|
18
|
+
|
19
|
+
conn_params[:password] ||= generate_password(conn_params)
|
20
|
+
|
21
|
+
super(conn_params)
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def generate_password(conn_params)
|
27
|
+
endpoint = conn_params.fetch(:host)
|
28
|
+
region = ENV["AWS_REGION"] || ENV["AWS_DEFAULT_REGION"] || "us-east-1"
|
29
|
+
|
30
|
+
credentials = Aws::CredentialProviderChain.new.resolve
|
31
|
+
|
32
|
+
token_generator = Aws::DSQL::AuthTokenGenerator.new(credentials: credentials)
|
33
|
+
|
34
|
+
token_generator.generate_db_connect_admin_auth_token(endpoint: endpoint, region: region)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def configure_connection
|
39
|
+
# PostgreSQLAdapter sets a bunch of parameters here which DSQL doesn't support
|
40
|
+
end
|
41
|
+
|
42
|
+
# https://docs.aws.amazon.com/aurora-dsql/latest/userguide/working-with-postgresql-compatibility-unsupported-features.html
|
43
|
+
|
44
|
+
def supports_views?
|
45
|
+
false
|
46
|
+
end
|
47
|
+
|
48
|
+
def supports_materialized_views?
|
49
|
+
false
|
50
|
+
end
|
51
|
+
|
52
|
+
def supports_extensions?
|
53
|
+
false
|
54
|
+
end
|
55
|
+
|
56
|
+
def supports_index_sort_order?
|
57
|
+
false
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
data.tar.gz.sig
ADDED
Binary file
|
metadata
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: activerecord-dsql-adapter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Samuel Cochran
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain:
|
11
|
+
- |
|
12
|
+
-----BEGIN CERTIFICATE-----
|
13
|
+
MIIDKDCCAhCgAwIBAgIBAzAN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M
|
28
|
+
G8WXc9zUMVewWkEjS9s++xFNb/7f4dFNXCoE3pgHjzctt7gYcJVacprsg925LYHO
|
29
|
+
WsbnbEow7BPlYOZm3rDIsEYpWqxN0lR8BakO2ToJ5RAHXahFu4K4eJtAsLk=
|
30
|
+
-----END CERTIFICATE-----
|
31
|
+
date: 2024-12-04 00:00:00.000000000 Z
|
32
|
+
dependencies:
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: activerecord
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: 7.2.0
|
40
|
+
type: :runtime
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 7.2.0
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: pg
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '1.1'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '1.1'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: aws-sdk-dsql
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
type: :runtime
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
description:
|
76
|
+
email:
|
77
|
+
- sj26@sj26.com
|
78
|
+
executables: []
|
79
|
+
extensions: []
|
80
|
+
extra_rdoc_files: []
|
81
|
+
files:
|
82
|
+
- README.md
|
83
|
+
- lib/active_record/connection_adapters/dsql_adapter.rb
|
84
|
+
- lib/activerecord-dsql-adapter.rb
|
85
|
+
homepage: https://github.com/sj26/activerecord-dsql-adapter
|
86
|
+
licenses: []
|
87
|
+
metadata:
|
88
|
+
homepage_uri: https://github.com/sj26/activerecord-dsql-adapter
|
89
|
+
source_code_uri: https://github.com/sj26/activerecord-dsql-adapter
|
90
|
+
changelog_uri: https://github.com/sj26/activerecord-dsql-adapter/releases
|
91
|
+
post_install_message:
|
92
|
+
rdoc_options: []
|
93
|
+
require_paths:
|
94
|
+
- lib
|
95
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: 3.0.0
|
100
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
requirements: []
|
106
|
+
rubygems_version: 3.5.16
|
107
|
+
signing_key:
|
108
|
+
specification_version: 4
|
109
|
+
summary: ActiveRecord adapter for AWS Aurora DSQL (PostgreSQL)
|
110
|
+
test_files: []
|
metadata.gz.sig
ADDED
Binary file
|