|
Project Information
Links
|
This short Perl script provides a simple command line interface to Amazon SimpleDB. It requires you to also install the Perl modules provided by Amazon. The latest version of this script can be found here: http://simpledb-cli.notlong.com/ Here is the manpage extracted from the script including installation instructions: NAME
simpledb - Amazon SimpleDB command line interface
SYNOPSIS
simpledb [opts] create-domain DOMAIN
simpledb [opts] delete-domain DOMAIN
simpledb [opts] list-domains
simpledb [opts] put DOMAIN ITEM [NAME=VALUE]...
simpledb [opts] put-replace DOMAIN ITEM [NAME=VALUE]...
simpledb [opts] get DOMAIN ITEM [NAME]...
simpledb [opts] delete DOMAIN ITEM [NAME[=VALUE]]...
simpledb [opts] select SELECTEXPRESSION
OPTIONS
--help Print help and exit.
--aws-access-key-id KEY
AWS access key id
[Defaults to $AWS_ACCESS_KEY_ID environment variable]
--aws-secret-access-key SECRETKEY
AWS secret access key
[Defaults to $AWS_SECRET_ACCESS_KEY environment variable]
--max COUNT
Maximum number of domains/items to retrieve and list.
[Defaults to all]
--separator STRING
Separator between attribute name and value.
[Defaults to equals (=)]
ARGUMENTS
DOMAIN Domain name
ITEM Item name
NAME Attribute name
VALUE Attribute value
SELECTEXPRESSION SimpleDB select expression
DESCRIPTION
This utility provides a simple command line interface to most Amazon
SimpleDB (SDB) actions.
EXAMPLES
# The following examples assume you have set these environment
variables:
export AWS_ACCESS_KEY_ID=...
export AWS_SECRET_ACCESS_KEY=...
# Create a new SimpleDB domain:
simpledb create-domain mydomain
# List the domains for this account:
simpledb list-domains
# Create some items with attribute name=value pairs:
simpledb put mydomain item1 key1=valueA key2=value2 x=why
simpledb put mydomain item2 key1=valueB key2=value2 y=zee
# Add another value for an attribute on an item:
simpledb put mydomain item2 y=zed when=now who=you
# Replace all values for specific attributes on an item:
simpledb put-replace mydomain item1 key1=value1 newkey=newvalue
# Delete all values for specific attributes on an item:
simpledb delete mydomain item1 x
# Delete specific values for specific attributes on an item:
simpledb delete mydomain item2 who=you
# List all item names in a domain
simpledb select 'select itemName() from mydomain'
# List all items and their attributes matching a given select query:
simpledb select 'select * from mydomain where key2="value2"'
# List all attributes on an item:
simpledb get mydomain item1
simpledb get mydomain item2
# List specific attributes on an item:
simpledb get mydomain item2 key2 y
# Delete the entire SimpleDB domain including all items and attributes:
simpledb delete-domain mydomain
ENVIRONMENT
AWS_ACCESS_KEY_ID
Default AWS access key id
AWS_SECRET_ACCESS_KEY
Default AWS secret access key
FILES
$HOME/.awssecret
If the above fail, then the keys are sought here in the
format expected by the "aws" toolkit (one per line):
access_key_id
secret_access_key
/etc/passwd-s3fs
If all of the above fail, then the keys are sought
here in the format expected by s3fs (colon separated):
access_key_id:secret_access_key
INSTALLATION
BEWARE! The installation of dependencies is somewhat messy with this
release and may require some understanding of how Perl works!
This tool depends on the following Perl modules from CPAN:
Getopt::Long
Pod::Usage
Digest::SHA1
Digest::HMAC
XML::Simple
You can install them using the "cpan" command on many Linux distros:
sudo cpan Getopt::Long Pod::Usage Digest::SHA1 Digest::HMAC XML::Simple
This tool also depends on the Amazon::SDB modules provided by Amazon
(not the one in CPAN). Amazon's modules can be found here:
http://developer.amazonwebservices.com/connect/entry.jspa?externalID=1136
Here is how I installed them.
curl -Lo amazon-simpledb-perl-library.zip \
http://amazon-simpledb-perl-library.notlong.com
unzip amazon-simpledb-perl-library.zip
sitelib=$(perl -MConfig -le 'print $Config{sitelib}')
sudo scp -r amazon-simpledb-*-perl-library/src/Amazon $sitelib
Finally, this command line interface can be installed with:
sudo curl -Lo /usr/local/bin/simpledb http://simpledb-cli.notlong.com
sudo chmod +x /usr/local/bin/simpledb
SEE ALSO
Latest versions of this script available from the Google Code project:
http://code.google.com/p/amazon-simpledb-cli/
Amazon SimpleDB (SDB)
http://www.amazon.com/SimpleDB-AWS-Service-Pricing/b/?node=342335011
Amazon SimpleDB Developer Guide
http://docs.amazonwebservices.com/AmazonSimpleDB/2007-11-07/DeveloperGui
de/
sdbShell (another SimpleDB command line interface by David Kavanagh)
http://code.google.com/p/typica/
CAVEATS
As currently written this tool does not support keys containing equal
signs (=).
Output will be difficult to parse if the values contain newlines.
HISTORY
2010-04-20 Eric Hammond <ehammond@thinksome.com>
- Removed support for "query". Please migrate to "select"
2009-09-01 Peter Kaminski <kaminski@istori.com>
- Added utf8 binmode for STDOUT
- Added select method
2009-03-16 Eric Hammond <ehammond@thinksome.com>
- Fix --max options and large result sets without --max
http://code.google.com/p/amazon-simpledb-cli/issues/detail?id=2
2008-06-09 Eric Hammond <ehammond@thinksome.com>
- Fallback to finding keys in $HOME/.awssecret or /etc/passwd-s3fs
2008-06-03 Eric Hammond <ehammond@thinksome.com>
- Completed --max option
- bugfix: Corrected --aws-secret-access-key option spelling
2008-05-26 Eric Hammond <ehammond@thinksome.com>
- Original release
|