如何在Azure Cosmos DB中导入图形数据库的数据?

如何在Azure Cosmos DB中导入图形数据库的数据?,azure,azure-cosmosdb,Azure,Azure Cosmosdb,这些文档表明,有一种数据迁移工具,仅在将数据导入Azure Cosmos DB以与DocumentDB API一起使用时有效,而不是在表API或图形API中有效。那么,有没有办法从其他来源导入数据以用于CosmosDB图形数据库呢?我下载了graph API演示项目,对这种类型的数据非常感兴趣 然后使用文本文件手动建立查询: --INIT --g.V().drop() --CREATE ------ --vertex g.addV('person').property('id', 'dav

这些文档表明,有一种数据迁移工具,仅在将数据导入Azure Cosmos DB以与DocumentDB API一起使用时有效,而不是在表API或图形API中有效。那么,有没有办法从其他来源导入数据以用于CosmosDB图形数据库呢?

我下载了graph API演示项目,对这种类型的数据非常感兴趣

然后使用文本文件手动建立查询:

--INIT
--g.V().drop()


--CREATE
------
--vertex
g.addV('person').property('id', 'dave').property('firstName', 'Dave').property('lastName', 'Andersen').property('age', 49)
g.addV('person').property('id', 'mary').property('firstName', 'Mary').property('lastName', 'Andersen').property('age', 39)
--edge
g.V('dave').addE('knows').to(g.V('mary'))


--READ
--filter
--g.V().hasLabel('person').order().by('firstName', decr)
--project
--g.V().hasLabel('person').values('firstName')
--traverse
--g.V('thomas').outE('knows').inV().hasLabel('person')
--loop
--g.V('thomas').repeat(out()).until(has('id', 'robin')).path()
--g.V().count()
--g.E().count()


--UPDATE
--------
--g.V('thomas').property('age', 44)


--DELETE
--dropedge
--g.V('thomas').outE('knows').where(inV().has('id', 'mary')).drop()
--dropvertex
--g.V('thomas').drop()
然后从代码中循环:

string queriesPath = AppDomain.CurrentDomain.BaseDirectory + "queries.txt";

            var queries = File.ReadAllLines(queriesPath).Where(l => !l.StartsWith("--") && !string.IsNullOrWhiteSpace(l));

            foreach (var query in queries)
            {
                Console.WriteLine("Running " + query);

                IDocumentQuery<dynamic> gremlinQuery = client.CreateGremlinQuery<dynamic>(graph, query);
                while (gremlinQuery.HasMoreResults)
                {
                    foreach (dynamic result in await gremlinQuery.ExecuteNextAsync())
                    {
                        Console.WriteLine($"\t {JsonConvert.SerializeObject(result)}");
                    }
                }

                Console.WriteLine();
            }
string querypath=AppDomain.CurrentDomain.BaseDirectory+“querys.txt”;
var querys=File.ReadAllLines(queryPath).Where(l=>!l.StartsWith(“--”)&!string.IsNullOrWhiteSpace(l));
foreach(查询中的var查询)
{
Console.WriteLine(“Running”+查询);
IDocumentQuery gremlinQuery=client.CreateGremlinQuery(图形,查询);
while(gremlinQuery.HasMoreResults)
{
foreach(wait gremlinQuery.ExecuteNextAsync()中的动态结果)
{
WriteLine($“\t{JsonConvert.SerializeObject(结果)}”);
}
}
Console.WriteLine();
}

对于图形api,它取决于您使用的数据库

  • 对于neo4j,有以下回购协议:
  • 对于arangodb,我可以使用数据迁移工具将顶点和边集上传为json,然后您可以编写一个简单的存储过程来连接垂直

我被困在跨图形集合(似乎不受支持)的查询点上,因此我们可能会上载同一集合中的边和顶点,并使用脚本制作边

此示例中的控制台应用程序可能会帮助您上载Azure Cosmos DB中图形数据库的示例数据。(如上传样本数据一节所述)。它不起作用。你能提供正确的网址吗?是否有任何方法将数据从sql数据库导入cosmos graph db?似乎已移动到: