Feb. 6, 2024, 7:40 a.m. | Abhishek Gupta

DEV Community dev.to

Posted: 6/Feb/2024


DynamoDB supports PartiQL to execute SQL-like select, insert, update, and delete operations.


Here is an example of how you would use PartiQL based queries for a simple URL shortener application. Notice how it uses a (generic) ExecuteStatement API to execute INSERT, SELECT, UPDATE and DELETE:



_, err := client.ExecuteStatement(context.Background(), &dynamodb.ExecuteStatementInput{
Statement: aws.String("INSERT INTO url_metadata value {'longurl':?,'shortcode':?, 'active': true}"),
Parameters: []types.AttributeValue{
&types.AttributeValueMemberS{Value: "https://github.com/abhirockzz"},
&types.AttributeValueMemberS{Value: uuid.New().String()[:8]},
},
})

_, err := client.ExecuteStatement(context.Background(), &dynamodb.ExecuteStatementInput{
Statement: aws.String("SELECT * FROM url_metadata where shortcode=? …

api application cloud database delete dynamodb language notice operations query select serverless simple sql update url

Azure DevSecOps Cloud Engineer II

@ Prudent Technology | McLean, VA, USA

Security Engineer III - Python, AWS

@ JPMorgan Chase & Co. | Bengaluru, Karnataka, India

SOC Analyst (Threat Hunter)

@ NCS | Singapore, Singapore

Managed Services Information Security Manager

@ NTT DATA | Sydney, Australia

Senior Security Engineer (Remote)

@ Mattermost | United Kingdom

Penetration Tester (Part Time & Remote)

@ TestPros | United States - Remote