Is it possible to save datetime to DynamoDB?

前端 未结 8 1410
清酒与你
清酒与你 2021-01-17 09:46

I have the next code:

users_table = Table(users_table_name, connection=Core.aws_dynamodb_connection)
users_table.put_item(data={
  \"login\": login,
  \"pass         


        
8条回答
  •  Happy的楠姐
    2021-01-17 10:00

    old post but maybe still interesting ..

    What you can do and how it worked for me:

    import datetime
    from datetime import datetime
    
    ...
    
    now = datetime.now()
    x = now.strftime("%m/%d/%Y, %H:%M:%S")
    
     table.put_item(
               Item={
                   'Index': Index,
               
                   'Stamp': x,
                   
                }
            )
    
    

    And with adaption to the code above:

    import datetime
    from datetime import datetime
    
    ...
    
    now = datetime.now()
    x = now.strftime("%m/%d/%Y, %H:%M:%S")
    
    users_table = Table(users_table_name, connection=Core.aws_dynamodb_connection)
    users_table.put_item(data={
      "login": login,
      "password": hashlib.sha256(password.encode("utf-8")).hexdigest(),
      "profile": profile,
      "registration_date": x, 
    })   
    

    My Output

提交回复
热议问题