Operate DynamoDB from Python like SQL.

set up


pip install dql 

code


import dql
import boto3
import os
table_name=os.environ['TABLE_NAME'] # dynamodb


engine = dql.Engine()
c = engine.connect(
    region=os.environ['AWS_DEFAULT_REGION'],
    access_key=os.environ['AWS_ACCESS_KEY_ID'],
    secret_key=os.environ['AWS_SECRET_ACCESS_KEY'],
    host=os.environ['HOST'],
    port=int(os.environ['PORT']),
    is_secure=False
)
print("--scan--")
results = engine.execute(f"SCAN * FROM {table_name} LIMIT 10")
for item in results:
    print(dict(item))

print("--delete--")
results = engine.execute(f"DELETE FROM {table_name} WHERE tm>=1235 and tm<=1236")

print("--scan--")
results = engine.execute(f"SCAN * FROM {table_name} LIMIT 10")
for item in results:
    print(dict(item))

See below for other queries. https://dql.readthedocs.io/en/latest/topics/queries/index.html

memorandum

DQL documentation https://dql.readthedocs.io/en/latest/ref/dql.engine.html

The actual state of connection is called DynamoDB Connection of dynamo3 module. https://pypi.org/project/dynamo3

Video and Docker-compose

IMAGE ALT TEXT HERE

As explained in the video, I also created a Docker-compose environment.

Recommended Posts

Operate DynamoDB from Python like SQL.
Operate Dynamodb from Lambda like SQL
sql from python
Operate Filemaker from Python
Operate neutron from Python!
Operate LXC from Python
Operate an I2C-connected display from Python
Try using Amazon DynamoDB from Python
Operate Sakura's cloud object storage from Python
MeCab from Python
Operate the schedule app using python from iphone
Use thingsspeak from python
Touch MySQL from Python 3
Operate Redmine using Python Redmine
Operate mongoDB from python in ubuntu environment ① Introduction of mongoDB
Use fluentd from python
Access bitcoind from python
Changes from Python 3.0 to Python 3.5
Changes from Python 2 to Python 3.0
Python from or import
Use MySQL from Python
[AWS] Operate SQS from SDK (send / receive) [Python] [Node.js]
Run python from excel
Install python from source
Operate Kinesis with Python
Use DynamoDB with Python
Execute command from Python
DynamoDB Script Memo (Python)
Use MySQL from Python
Operate Blender with Python
Manipulate riak from python
Force Python from Fortran
Use BigQuery from python.
Execute command from python
Operate Excel with Python (1)
[Python] Read From Stdin
ODBC access to SQL Server from Linux with Python
Use mecab-ipadic-neologd from python
Operate Excel with Python (2)
Flatten using Python yield from
Call CPLEX from Python (DO cplex)
Deep Python learned from DEAP
Operate Excel with Python openpyxl
Register DynamoDB x Python / Decimal
Post from Python to Slack
Operate TwitterBot with Lambda, Python
Grammar features added from Python3.6
Cheating from PHP to Python
Make MeCab available from Python3
Information obtained from tweet_id (Python)
OCR from PDF in Python
Run illustrator script from python
Use MySQL from Anaconda (python)
Anaconda updated from 4.2.0 to 4.3.0 (python3.5 updated to python3.6)
Study from Python Hour4: Object-oriented ②
Query Athena from Lambda Python
Access Oracle DB from Python
[Note] Operate MongoDB with Python
Study from Python Hour3: Functions
Start / stop GCE from python
Aim python library master (32) sql