你好,我对Python相当陌生,我正在尝试将Flask上的现有应用程序转换为Quart(https://gitlab.com/pgjones/quart),它应该构建在asyncio之上,所以我可以使用Goblin OGM 与 JanusGraph 或 TinkerPop 交互。根据我在 Goblin 上找到的示例,我需要获取一个事件循环来异步运行命令。
>>> import asyncio
>>> from goblin import Goblin
>>> loop = asyncio.get_event_loop()
>>> app = loop.run_until_complete(
... Goblin.open(loop))
>>> app.register(Person, Knows)
Run Code Online (Sandbox Code Playgroud)
然而,我找不到从 Quart 获取事件循环的方法,即使它是构建在 asyncio 之上的。
有谁知道我怎样才能得到它?任何帮助将不胜感激。
使用 TinkerPop/JanusGraph 时,我可以定义 VertexLabels 和属性键,然后可以使用它们来创建复合索引。我在 Neptune 文档的某处读到索引不是必需的(或支持的)。
我的问题是,在将数据加载到数据库时如何防止重复?我在 AWS 文档中找到的唯一示例涉及加载已为每条记录提供唯一 ID 的数据,对我来说,这似乎需要首先从 RDBMS 中提取数据,以便在我之前获得所有 ID 及其关系。可以加载它。
我的理解是否正确,如果不正确我该如何解决这个问题?
我已经在 python 应用程序中苦苦挣扎了几天,我希望在一个文件夹中查找一个或多个文件,并遍历每个文件和其中的每个记录,并创建要保留在 Janusgraph 数据库上的对象。我正在使用的特定 OGM 要求使用 asyncio 以异步方式完成与数据库的事务。我已经阅读了很多关于 asyncio 的博客和帖子,我想我理解 async、await、tasks 等的概念......在我的应用程序中,我定义了几个处理不同部分处理的函数:
我理解(我可能是错的)使用 asyncio 的最大优势是在调用函数通常会因 I/O、数据库事务、网络延迟等而阻塞的情况下......
所以我的问题是我是否需要将所有函数转换为协程并安排运行事件循环,或者只是那些会阻塞的函数,例如将事务提交到数据库。我一开始就尝试过这种方法,但遇到了各种各样的问题。
我将 JanusGraph 与 Cassandra 和 ElasticSearch 后端一起使用。我使用以下脚本来创建我的架构和索引。
// Create a Janus Graph instance, according to the configuration file provided
// in the open() method below, and define the schema and index.
// This is intended to be loaded and run inside the Gremlin Console from the Janus
// Graph download. Usage :load janus-ualschema.groovy
println "\n=======================================";[]
println "Creating in-memory Janus Graph instance";[]
println "=======================================\n";[]
// Create a new graph instance
graph = JanusGraphFactory.open("conf/janusgraph-useractivitylogs.properties")
mgmt = graph.openManagement()
println "\n====================";[]
println "Defining EDGE …Run Code Online (Sandbox Code Playgroud)