如果在dynamodb中使用json,我将如何在python中使用/*
Font-size is fluid.
It will be 16px when it reaches 300px width of the viewport
and 30px when it reaches 1500px of the viewport. Beyond and below those
breakpoints
font-size will be also fluid but we can restrict this using @media queries.
For example we can restrict that after viewport has reached the width of 1500px
the font size will be set as the fixed point (e.g. 2em).
*/
HTML {
font-family: Montserrat, sans-serif;
font-size: calc(16px + (30 - 16) * (100vw - 300px) / (1500 - 300) );
}
/*
Notes:
-*- The rem unit:
* In IE9 and IE10, using rem with the shorthand `font` property will make the whole declaration invalid.
Also, these two browsers don’t support rem units on pseudo elements.
-*- Viewport units (vw, vh, vmin, vmax):
* IE11 and Edge don’t support the vmax unit.
-*- Calc:
* calc with px and viewport units might not work in Safari, so
we can replace px units with percentages, in order to use it with viewport
units.
* calc with percentages is totally broken on IE (both 11 and Edge)
so you can use a regular calc() function with the em unit,
followed by a -webkit-calc() function with the percentage unit
*/
@media screen and (min-width: 1500px) {
HTML {
font-size: 1.875em; /*~30px*/
}
}
搜索session.id == "12ghbcyg"
中的任何项目?
boto3
答案 0 :(得分:2)
以下是使用contains扫描的示例。请注意,如果桌子上有数百万件物品,扫描是一项代价高昂的操作。通常,如果您不知道分区键值,则使用扫描。即使您不知道分区键值,最推荐的解决方案是使用全局二级索引(GSI)并直接查询索引而不是表。
您可能需要浏览上述选项并确定适合您的用例的方法。
以下代码旨在介绍如何使用使用包含的SCAN API。如果您知道分区键值,则可以在QUERY API上类似地使用CONTAINS。
扫描使用包含: -
from __future__ import print_function # Python 2/3 compatibility
import boto3
from botocore.exceptions import ClientError
import json
import decimal
from boto3.dynamodb.conditions import Key, Attr
# Helper class to convert a DynamoDB item to JSON.
class DecimalEncoder(json.JSONEncoder):
def default(self, o):
if isinstance(o, decimal.Decimal):
if o % 1 > 0:
return float(o)
else:
return int(o)
return super(DecimalEncoder, self).default(o)
dynamodb = boto3.resource('dynamodb', region_name='us-west-2', endpoint_url="http://localhost:8000")
table = dynamodb.Table('usertable')
print("Scanning...")
sessionData = {
"id": "12ghbcyg",
"foo": "bar"
}
fe = Attr('sessions').contains(sessionData)
response = table.scan(
FilterExpression=fe
)
for i in response['Items']:
print(json.dumps(i, cls=DecimalEncoder))
while 'LastEvaluatedKey' in response:
response = table.scan(
FilterExpression=fe,
ExclusiveStartKey=response['LastEvaluatedKey']
)
for i in response['Items']:
print(json.dumps(i, cls=DecimalEncoder))