我想在query_entities上使用过滤器来存储Azure表。
我试图使用像这样的过滤器: Table = table_service.query_entities('MyTableName',filter =“ RowKey eq 20”)
#coding:utf-8
import os
import json
from azure import *
from azure.storage import *
from azure.storage.table import TableService, Entity
table_service = TableService(account_name='MyAccountName',
sas_token='MySASToken')
Table = table_service.query_entities('MyTableName', filter = "Country eq
USA")
print(Table.items)
我有一个例外:
azure.common.AzureHttpError:错误的请求 {“ odata.error”:{“ code”:“ InvalidInput”,“ message”:{“ lang”:“ zh-CN”,“ value”:“ A 检测到类型不兼容的二进制运算符。找到的操作数 运算符类型为“ Edm.String”和“ Edm.Int32” '等于'。\ nRequestId:ef3858e7-5002-00d0-617f-0d374a000000 \ n时间:2019-05-18T13:45:23.6288160Z“}}}
我尝试更改为:
Table = table_service.query_entities('MyTableName', filter = "Country eq
USA")
但是我收到了SyntaxError:无效的语法
答案 0 :(得分:0)
尝试使用此过滤器:
Country eq 'USA'
基本上,您属性的数据类型为String
,因此该值必须用单引号引起来。
同样的情况也适用于您的RowKey
查询:
RowKey eq '20'
您可以在此处找到更多示例:https://docs.microsoft.com/en-us/rest/api/storageservices/querying-tables-and-entities#sample-query-expressions。
答案 1 :(得分:0)
由于相等的比较,您得到了第一个例外:type Triple = Triple of int * int * int
with
static member inline (+) (t1, t2) =
match t1, t2 with
| Triple (a1, a2, a3), Triple (b1, b2, b3) -> Triple (a1 + b1, a2 + b2, a3 + b3)
//add other functionality like map, fold, etc you'd normally expect from Arrays
let t1 = Triple (1, 2, 3)
let t2 = Triple (4, 5, 6)
t1 + t2 //val it : Triple = Triple (5,7,9)
。
检查表说明,在异常消息中说您正在执行“找到运算符类型'Equal'的操作数类型'Edm.String'和'Edm.Int32'”。 type GenericTriple<'a> = GenericTriple of 'a * 'a * 'a
with
static member // etc...
可能是import tkinter
import threading
import math
# Creating root Widget to contain Canvas.
rootWidget = tkinter.Tk()
# Creating Canvas for Drawing Shapes.
canvas = tkinter.Canvas(bg = "purple",height = 400,width = 400)
# Drawing Rectangle.
rectangle = canvas.create_rectangle(200,100,210,110,fill =
"brown")
# Defining Function and Button to Move Rectangle.
x_c,y_c,x,y,radius,angle = 200,200,0,0,15,0
def move_rectangle():
global x
global y
global angle
# Rotating Rectangle.
x = x_c+radius*math.cos(angle)
y = y_c+radius*math.sin(angle)
print(x,y)
canvas.move(rectangle,x,y)
# Incrementing angle.
angle = angle+0.4
# Creating Canvas.
canvas.pack()
# Creating and Staring Animation Engine.
timer,count = 0,0
def engine():
global count
global timer
if count<150:
timer = threading.Timer(0.4,engine).start()
move_rectangle()
print("Moving Rectangle ! "+str(count))
count = count+1
engine()
# Creating GUI Loop.
rootWidget.mainloop()
# Ending Program.
print("Program Ended !")
,因此请确保您比较的是同一类型。
还有第二个例外,尽管您没有发布完整的追溯,我怀疑您删除了最后一行的括号。
答案 2 :(得分:0)
我已经尝试过了,并且效果很好:
Table = table_service.query_entities('MyTableName', filter = "Country eq
'USA'")