forked from saymedia/python-simpledb
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsdbimport.py
More file actions
36 lines (25 loc) · 824 Bytes
/
Copy pathsdbimport.py
File metadata and controls
36 lines (25 loc) · 824 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import simplejson
def sdbimport(sdb, domain, items):
# If the domain doesn't exist, create it.
if not sdb.has_domain(domain):
domain = sdb.create_domain(domain)
else:
domain = sdb[domain]
# Load the items.
for name, value in items.iteritems():
domain[name] = value
if __name__ == '__main__':
import os
import sys
sys.path.insert(1, os.path.normpath(os.path.join(sys.path[0], '..')))
import simpledb
import settings
if len(sys.argv) != 3:
print 'Usage: python sdbimport.py <domain> <json_file>'
sys.exit(1)
print "Loading..."
items = simplejson.load(open(sys.argv[2]))
print "Importing..."
sdb = simpledb.SimpleDB(settings.AWS_KEY, settings.AWS_SECRET)
sdbimport(sdb, sys.argv[1], items)
print "All done."