dql package

Module contents

Simple SQL-like query language for dynamo.

class dql.Engine(connection=None)[source]

Bases: object

DQL execution engine

Parameters:
connection : DynamoDBConnection, optional

If not present, you will need to call Engine.connect()

Attributes:
caution_callback : callable, optional

Called to prompt user when a potentially dangerous action is about to occur.

cloudwatch_connection[source]

Lazy create a connection to cloudwatch

connect(*args, **kwargs)[source]

Proxy to DynamoDBConnection.connect.

connection[source]

Get the dynamo connection

describe(tablename: str, refresh: bool = False, metrics: bool = False, require: bool = False) → Optional[dql.models.TableMeta][source]

Get the TableMeta for a table

describe_all(refresh=True)[source]

Describe all tables in the connected region

execute(commands, pretty_format=False)[source]

Parse and run a DQL string

Parameters:
commands : str

The DQL command string

pretty_format : bool

Pretty-format the return value. (e.g. 4 -> ‘Updated 4 items’)

get_capacity(tablename: str, index_name: Optional[str] = None) → Tuple[float, float][source]

Get the consumed read/write capacity

region[source]

Get the connected dynamo region or host

class dql.FragmentEngine(connection=None)[source]

Bases: dql.engine.Engine

A DQL execution engine that can handle query fragments

execute(fragment, pretty_format=True)[source]

Run or aggregate a query fragment

Concat the fragment to any stored fragments. If they form a complete query, run it and return the result. If not, store them and return None.

partial[source]

True if there is a partial query stored

pformat_exc(exc)[source]

Format an exception message for the last query’s parse error

reset()[source]

Clear any query fragments from the engine

class dql.DQLClient(completekey='tab', stdin=None, stdout=None)[source]

Bases: cmd.Cmd

Interactive commandline interface.

Attributes:
running : bool

True while session is active, False after quitting

engine : dql.engine.FragmentEngine
caution_callback(action)[source]

Prompt user for manual continue when doing write operation on all items in a table

complete_file(text, line, *_)[source]

Autocomplete DQL file lookup

complete_ls(text, *_)[source]

Autocomplete for ls

complete_opt(text, line, begidx, endidx)[source]

Autocomplete for options

complete_opt_allow_select_scan(text, *_)[source]

Autocomplete for allow_select_scan option

complete_opt_display(text, *_)[source]

Autocomplete for display option

complete_opt_format(text, *_)[source]

Autocomplete for format option

complete_opt_lossy_json_float(text, *_)[source]

Autocomplete for lossy_json_float option

complete_opt_pagesize(*_)[source]

Autocomplete for pagesize option

complete_opt_width(*_)[source]

Autocomplete for width option

complete_use(text, *_)[source]

Autocomplete for use

complete_watch(text, *_)[source]

Autocomplete for watch

completedefault(text, line, *_)[source]

Autocomplete table names in queries

default(command)[source]

This is an override of super class method.

do_EOF()[source]

Exit

do_exit()[source]

Exit

do_file(filename)[source]

Read and execute a .dql file

do_local(host='localhost', port=8000)[source]

Connect to a local DynamoDB instance. Use ‘local off’ to disable.

> local > local host=localhost port=8001 > local off

do_ls(table: str = None) → None[source]

List all tables or print details of one table

do_opt(*_args, **kwargs)[source]

Get and set options

do_shell(arglist)[source]

Run a shell command

do_throttle(*_args)[source]

Set the allowed consumed throughput for DQL.

# Set the total allowed throughput across all tables > throttle 1000 100 # Set the default allowed throughput per-table/index > throttle default 40% 20% # Set the allowed throughput on a table > throttle mytable 10 10 # Set the allowed throughput on a global index > throttle mytable myindex 40 6

see also: unthrottle

do_unthrottle(*args)[source]

Remove the throughput limits for DQL that were set with ‘throttle’

# Remove all limits > unthrottle # Remove the limit on total allowed throughput > unthrottle total # Remove the default limit > unthrottle default # Remove the limit on a table > unthrottle mytable # Remove the limit on a global index > unthrottle mytable myindex

do_use(region)[source]

Switch the AWS region

> use us-west-1 > use us-east-1

do_watch(*args)[source]

Watch Dynamo tables consumed capacity

emptyline()[source]

Called when an empty line is entered in response to the prompt.

If this method is not overridden, it repeats the last nonempty command entered.

formatter = None[source]
getopt_default(option)[source]

Default method to get an option

getopt_display()[source]

Get value for display option

getopt_format()[source]

Get value for format option

help_alter()[source]

Print the help text for ALTER

help_analyze()[source]

Print the help text for ANALYZE

help_create()[source]

Print the help text for CREATE

help_delete()[source]

Print the help text for DELETE

help_drop()[source]

Print the help text for DROP

help_dump()[source]

Print the help text for DUMP

help_explain()[source]

Print the help text for EXPLAIN

help_help()[source]

Print the help text for help

help_insert()[source]

Print the help text for INSERT

help_load()[source]

Print the help text for LOAD

help_opt()[source]

Print the help text for options

help_scan()[source]

Print the help text for SCAN

help_select()[source]

Print the help text for SELECT

help_update()[source]

Print the help text for UPDATE

initialize(region: str = 'us-west-1', host: str = None, port: int = 8000, config_dir: Optional[str] = None, session: Optional[Any] = None) → None[source]

Set up the repl for execution.

load_config()[source]

Load your configuration settings from a file

opt_allow_select_scan(allow)[source]

Set option allow_select_scan

opt_display(display)[source]

Set value for display option

opt_format(fmt)[source]

Set value for format option

opt_lossy_json_float(lossy)[source]

Set option lossy_json_float

opt_pagesize(pagesize)[source]

Get or set the page size of the query output

opt_width(width)[source]

Set width of output (‘auto’ will auto-detect terminal width)

postcmd(stop, line)[source]

Hook method executed just after a command dispatch is finished.

run_command(command: str, use_json: bool = False, raise_exceptions: bool = False) → None[source]

Run a command passed in from the command line with -c

running = False[source]
save_config()[source]

Save the conf file

session = None[source]
start()[source]

Start running the interactive session (blocking)

update_prompt()[source]

Update the prompt