Spaces:
Configuration error

File size: 598 Bytes
681c53e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24

import boto3

class DynamoDBService:
    def __init__(self, table_name):
        
        self.dynamodb = boto3.resource('dynamodb')
        self.table = self.dynamodb.Table(table_name)
        return table_name

    def put_item(self, item):
        
        response = self.table.put_item(Item=item)
        return response

    def get_item(self, key):
        
        response = self.table.get_item(Key=key)
        return response

# Singleton olarak bir tabloya bağlanmak için aşağıdaki gibi tanımlayabilirsiniz
dynamodb_service = DynamoDBService('new_table')