Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
from datetime import datetime
import pytz
from pynamodb.models import Model
from pynamodb.attributes import NumberAttribute, UTCDateTimeAttribute
class MyModel(Model):
class Meta:
table_name = 'my_model'
read_capacity_units = 10
write_capacity_units = 10
host = "http://localhost:8000"
k = NumberAttribute(hash_key=True)
t = UTCDateTimeAttribute()
m1 = MyModel()
m1.k = 123
m1.t = datetime.utcnow()
print(m1.t, m1.t.tzinfo)
m2 = MyModel.get(123)
print(m2.t, m2.t.tzinfo)
m2.t = datetime.utcnow().replace(tzinfo=pytz.utc)
m3 = MyModel.get(123)
print(m3.t, m3.t.tzinfo)
m3.t =
print(m3.t, m3.t.tzinfo)
m4 = MyModel.get(123)
print(m4.t, m4.t.tzinfo)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment