Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ take on [dbext.vim][], improving on it on the following ways:
* Supports a modern array of backends, including NoSQL databases:
- Big Query
- ClickHouse
- DynamoDB
- DuckDB
- Impala
- jq
Expand Down
43 changes: 43 additions & 0 deletions autoload/db/adapter/dynamodb.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
function! s:command(url, output) abort
let url = db#url#parse(a:url)
let endpoint_url = []
if has_key(url, 'user')
let profile = url.user
let http_url = 'http://' .. url.host .. ':' .. url.port
let endpoint_url = ['--endpoint-url', http_url]
else
if has_key(url, 'host')
let profile = url.host
else
let profile = 'default'
endif
endif
return ['aws', 'dynamodb', '--profile', profile, '--output', a:output] + endpoint_url
endfunction

function! db#adapter#dynamodb#input_extension() abort
return 'js'
endfunction

function! db#adapter#dynamodb#output_extension() abort
return 'json'
endfunction

function! db#adapter#dynamodb#input(url, in) abort
if filereadable(a:in)
let lines = readfile(a:in)
return ['sh', '-c'] + [join(s:command(a:url, 'json') + split(lines[0]))]
endif
return ['echo', 'no', 'command']
endfunction

function! db#adapter#dynamodb#auth_input() abort
return v:false
endfunction

function! db#adapter#dynamodb#tables(url) abort
let cmd = s:command(a:url, 'text') + ['list-tables']
let out = db#systemlist(cmd)
return map(out, 'matchstr(v:val, "\\w*$")')
endfunction

14 changes: 14 additions & 0 deletions doc/dadbod.txt
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,20 @@ ClickHouse ~
<
Use the `secure` query parameter to enable TLS.

*dadbod-dynamodb*
DynamoDB ~
>
dynamodb://[<profile>@[host:port]]
dynamodb://[<profile>]
dynamodb://
<

Use @host:port to use on a local dynamodb instance, for real AWS
DynamoDB don't set any host and port.

Use any AWS credential file accepted by `aws` cli by profile_name
or environment variables before launching vim.

*dadbod-duckdb*
DuckDB ~
>
Expand Down