如何使用in_运算符正确构造查询(How to properly construct query with in_ operator)
我有一个带有IN语句的SQL更新查询,它通过SQLAlchemy执行。 不幸的是,当前的实现使用字符串插值,我想用更安全的选项替换它。
session.execute(''' UPDATE servers SET cpu_cores=st.cpu_cores, cpu_mhz=st.cpu_mhz, ram_mb=st.ram_mb FROM servers WHERE server.provider_id IN (%s) ''' % ','.join([ ... ]))
可以在这里用
in_
方法替换%
运算符吗? 或者我应该使用session.query
重新实现此查询?I have an SQL update query with IN statement which is executed via SQLAlchemy. Unfortunately current implementation uses string interpolation, which I'd like to replace with more secure option.
session.execute(''' UPDATE servers SET cpu_cores=st.cpu_cores, cpu_mhz=st.cpu_mhz, ram_mb=st.ram_mb FROM servers WHERE server.provider_id IN (%s) ''' % ','.join([ ... ]))
Is it possible to replace
%
operator within_
method here? Or I should re-implement this query usingsession.query
?
原文:https://stackoverflow.com/questions/38915733
最满意答案
你不应该抓住任何用户的饲料,公共与否。 您需要授权具有
user_posts
的用户才能访问其Feed - 以及他的Feed。此外,图形API中不再提供用户名,您现在需要使用App Scoped ID。 当您授权用户时,您就会得到它。
顺便说一句,根本不允许抓取: https : //www.facebook.com/apps/site_scraping_tos_terms.php
You are not supposed to grab the feed of any user, public or not. You need to authorize a user with
user_posts
to get access to his feed - and his feed only.Also, usernames are not available in the Graph API anymore, you need to use an App Scoped ID now. You get that when you authorize the user.
Btw, scraping is not allowed at all: https://www.facebook.com/apps/site_scraping_tos_terms.php
相关问答
更多-
首先是一些术语: 节点 - 基本上是“事物”,例如用户,照片,页面,评论 边缘 - “事物”之间的联系,例如Page's Photos或Photo's Comments 字段 - 有关这些“事物”的信息,例如某人的生日或页面的名称 当您向节点或边缘发出API请求时,通常不会在单个响应中收到该请求的所有结果。 这是因为某些响应可能包含数千个对象,因此默认情况下大多数响应都是分页的。 要获得用户的所有帖子,您有3个选项: 基于游标的分页 基于游标的分页是最有效的分页方法,应尽可能使用。 游标是指随机字符串,用于 ...
-
我知道这篇文章已经过时了,但我现在正在寻找它,并且从现在起Facebook更新了API,这里有一个解决方案: https://developers.facebook.com/docs/facebook-login/permissions/v2.3 您必须拥有read_stream的扩展权限。 编辑 | 页面上显示的限制是: 此权限授予在Facebook尚未提供的平台上构建Facebook品牌客户端的应用程序。 例如,Android和iOS应用不会被批准获得此权限。 此外,Web,桌面,车载和电视应用程序将不 ...
-
你不应该抓住任何用户的饲料,公共与否。 您需要授权具有user_posts的用户才能访问其Feed - 以及他的Feed。 此外,图形API中不再提供用户名,您现在需要使用App Scoped ID。 当您授权用户时,您就会得到它。 顺便说一句,根本不允许抓取: https : //www.facebook.com/apps/site_scraping_tos_terms.php You are not supposed to grab the feed of any user, public or not ...
-
Facebook图形API:如何按应用程序过滤家庭和饲料?(Facebook Graph API: How to filter home & feed by application?)[2023-06-17]
Facebook已经添加了支持,通过传递filter参数来过滤me/home帖子而不使用FQL。 例如,要获得照片,你可以做: me/home?filter=app_2305272732 完整的文档在这里: http : //developers.facebook.com/docs/reference/api/user/#home You can now run Facebook Query Language (FQL) queries using the Facebook Graph API (base ... -
对/me/home或/user_id/home进行API调用,其中user_id是当前会话用户。 您还使用旧的PHP SDK /* PHP SDK v4.0.0 */ /* make the API call */ $request = new FacebookRequest( $session, 'GET', '/me/home' ); $response = $request->execute(); $graphObject = $response->getGraphObject(); /* ...
-
从那时起,它很可能是一个已修复的错误,JSON正常工作,现在提供正确的类型 "type": "status", 有关发布到组的更多信息,请参阅https://developers.facebook.com/docs/reference/api/group/#feed It was most likely a bug that has been fixed since then, the JSON works correctly now giving the correct type as "type": ...
-
Facebook Graph API帖子,在Feed帖子上生成用户通知(Facebook Graph API post, generate user notification on feed post)[2023-01-17]
用户必须设置选项以在组中获取通知,否则他们不会收到新帖子的通知。 为了使所有用户都能看到新帖子,您需要在“App Review”标签中显示您的应用。 如果仍然无效,您应该提交错误。 Users have to set the option to get notifications in the group, else they don´t get a notification for new posts. In order to make new posts visible to all users, yo ... -
Facebook Graph API:没有隐私的GET / feed“SELF”(Facebook Graph API: GET /feed without privacy “SELF”)[2023-04-30]
我如何构建API请求(最好在图形的JavaScript API版本中)来获取/ feed中没有隐私值设置为“SELF”的所有内容? 没有办法实现这种过滤; 你必须在你的最后做到这一点。 到目前为止,我只是设法获取/提供其中包含隐私对象的对象,以便能够在客户端上处理它们 - 我不想这样做,因为API限制被快速且不必要地消耗掉了。 Facebook不提供更多过滤和排序功能的论点是它对性能不利 - 从FQL时代吸取的教训。 (来源:Facebook工程师在问答环节。) 因此,除了将您的应用程序视为在此实例中外包的 ... -
在做了一些研究之后,我发现这是不可能的,可以获取提要然后在type = page的基础上对其进行过滤,然后相应地使用它或单独访问{pageid} / feed以获取单个的提要页。 希望它可以帮助别人。 问候, 里诺琼斯 After doing some research, I found that this isn't properly possible, one can get feeds and then filter it on the basis of type=page and then use ...
-
在FQL中比使用Graph API更容易: SELECT post_id, actor_id, message, attachment, place, created_time, likes, description FROM stream WHERE source_id = me() AND actor_id = me() AND attachment.fb_object_type = 'photo' It's easier to do in FQL than with the Graph ...