目录

1.arangoimp方法

参数解析

全局配置部分(Global configuration)

  • --backslash-escape

use backslash as the escape character for quotes, used for csv (default: false)

  • --batch-size

size for individual data batches (in bytes) (default: 16777216)

  • --collection

collection name (default: "")

  • --configuration

the configuration file or 'none' (default: "")

  • --convert

convert the strings 'null', 'false', 'true' and strings containing numbers into non-string types (csv and tsv only) (default: true)

  • --create-collection

create collection if it does not yet exist (default: false)

  • --create-collection-type

type of collection if collection is created (edge or document). possible values: "document", "edge" (default: "document")

  • --file

file name ("-" for STDIN) (default: "")

  • --from-collection-prefix

_from collection name prefix (will be prepended to all values in '_from') (default: "")

  • --ignore-missing

ignore missing columns in csv input (default: false)

  • --on-duplicate

action to perform when a unique key constraint violation occurs. Possible values: ignore, replace, update, error. possible values: "error", "ignore", "replace", "update" (default: "error")

  • --overwrite

overwrite collection if it exist (WARNING: this will remove any data from the collection) (default: false)

  • --progress

show progress (default: true)

  • --quote

quote character(s), used for csv (default: """)

  • --remove-attribute <string...>

remove an attribute before inserting an attribute into a collection (for csv and tsv only) (default: )

  • --separator

field separator, used for csv and tsv (default: "")

  • --skip-lines

number of lines to skip for formats (csv and tsv only) (default: 0)

  • --threads

Number of parallel import threads. Most useful for the rocksdb engine (default: 2)

  • --to-collection-prefix

_to collection name prefix (will be prepended to all values in '_to') (default: "")

  • --translate <string...>

translate an attribute name (use as --translate "from=to", for csv and tsv only) (default: )

  • --type

type of import file. possible values: "auto", "csv", "json", "jsonl", "tsv" (default: "json")

  • --version

reports the version and exits (default: false)

Section 'log' (Configure the logging)

  • --log.color

use colors for TTY logging (default: true)

  • --log.level <string...>

the global or topic-specific log level (default: "info")

  • --log.output <string...>

log destination(s) (default: )

  • --log.role

log server role (default: false)

  • --log.use-local-time

use local timezone instead of UTC (default: false)

  • --log.use-microtime

use microtime instead (default: false)

Section 'server' (Configure a connection to the server)

  • --server.authentication

require authentication credentials when connecting (does not affect the server-side authentication settings) (default: true)

  • --server.connection-timeout

connection timeout in seconds (default: 5)

  • --server.database

database name to use when connecting (default: "_system")

  • --server.endpoint

endpoint to connect to, use 'none' to start without a server (default: "http+tcp://127.0.0.1:8529")

  • --server.password

password to use when connecting. If not specified and authentication is required, the user will be prompted for a password (default: "")

  • --server.request-timeout

request timeout in seconds (default: 1200)

  • --server.username

username to use when connecting (default: "root")

Section 'ssl' (Configure SSL communication)

  • --ssl.protocol

ssl protocol (1 = SSLv2, 2 = SSLv2 or SSLv3 (negotiated), 3 = SSLv3, 4 = TLSv1, 5 = TLSV1.2). possible values: 1, 2, 3, 4, 5 (default: 5)

Section 'temp' (Configure temporary files)

  • --temp.path

path for temporary files (default: "")

应用实例

  • 导入节点集合数据
arangoimp --server.endpoint tcp://127.0.0.1:8529 --server.username root --server.password ××× --server.database _system --file test.csv --type csv --create-collection true --create-collection-type document --overwrite true --collection "test"
  • 导入边集合数据
arangoimp --server.endpoint tcp://127.0.0.1:8529 --server.username root --server.password *** --server.database _system --file test.csv --type csv --create-collection true --create-collection-type document --overwrite true --collection "test"

python方法

单条导入

from arango import ArangoClient

# Initialize the ArangoDB client.
client = ArangoClient() # Connect to "test" database as root user.
db = client.db('test', username='root', password='passwd') # Get the API wrapper for "students" collection.
students = db.collection('students') # Create some test documents to play around with.
lola = {'_key': 'lola', 'GPA': 3.5, 'first': 'Lola', 'last': 'Martin'} # Insert a new document. This returns the document metadata.
metadata = students.insert(lola)

批量数据导入

由于每一次insert就会产生一次数据库连接,当数据规模较大时,一次次插入比较浪费网络资源,这时候就需要使用Transactions了

from arango import ArangoClient

# Initialize the ArangoDB client.
client = ArangoClient() # Connect to "test" database as root user.
db = client.db('test', username='root', password='passwd') # Get the API wrapper for "students" collection.
students = db.collection('students') # Begin a transaction via context manager. This returns an instance of
# TransactionDatabase, a database-level API wrapper tailored specifically
# for executing transactions. The transaction is automatically committed
# when exiting the context. The TransactionDatabase wrapper cannot be
# reused after commit and may be discarded after.
with db.begin_transaction() as txn_db: # Child wrappers are also tailored for transactions.
txn_col = txn_db.collection('students') # API execution context is always set to "transaction".
assert txn_db.context == 'transaction'
assert txn_col.context == 'transaction' # TransactionJob objects are returned instead of results.
job1 = txn_col.insert({'_key': 'Abby'})
job2 = txn_col.insert({'_key': 'John'})
job3 = txn_col.insert({'_key': 'Mary'}) # Upon exiting context, transaction is automatically committed.
assert 'Abby' in students
assert 'John' in students
assert 'Mary' in students # Retrieve the status of each transaction job.
for job in txn_db.queued_jobs():
# Status is set to either "pending" (transaction is not committed yet
# and result is not available) or "done" (transaction is committed and
# result is available).
assert job.status() in {'pending', 'done'} # Retrieve the job results.
metadata = job1.result()
assert metadata['_id'] == 'students/Abby' metadata = job2.result()
assert metadata['_id'] == 'students/John' metadata = job3.result()
assert metadata['_id'] == 'students/Mary' # Transactions can be initiated without using a context manager.
# If return_result parameter is set to False, no jobs are returned.
txn_db = db.begin_transaction(return_result=False)
txn_db.collection('students').insert({'_key': 'Jake'})
txn_db.collection('students').insert({'_key': 'Jill'}) # The commit must be called explicitly.
txn_db.commit()
assert 'Jake' in students
assert 'Jill' in students

参考资料

AranfoDB Document v3.3

python-arango document

欢迎转载,转载请注明网址:https://www.cnblogs.com/minglex/p/9705481.html

ArangoDB数据导入的更多相关文章

  1. ITTC数据挖掘平台介绍(五) 数据导入导出向导和报告生成

    一. 前言 经过了一个多月的努力,软件系统又添加了不少新功能.这些功能包括非常实用的数据导入导出,对触摸进行优化的画布和画笔工具,以及对一些智能分析的报告生成模块等.进一步加强了平台系统级的功能. 马 ...

  2. FineReport实现EXCEL数据导入自由报表

    在制作填报报表的时候,对于空白填报表,常常导出为Excel,派发给各部门人员填写后上交.如何能避免手动输入,直接将Excel中的数据导入到填报表中提交入库呢? 这里以一个简单的员工信息填报示例进行介绍 ...

  3. Execl数据导入sql server方法

    在日常的程序开发过程中,很多情况下,用户单位给予开发人员的数据往往是execl或者是access数据,如何把这些数据转为企业级是数据库数据呢,下面就利用sqlserver自带的功能来完成此项任务. 首 ...

  4. kettle将Excel数据导入oracle

    导读 Excel数据导入Oracle数据库的方法: 1.使用PL SQL 工具附带的功能,效率比较低 可参考这篇文章的介绍:http://www.2cto.com/database/201212/17 ...

  5. [Asp.net]常见数据导入Excel,Excel数据导入数据库解决方案,总有一款适合你!

    引言 项目中常用到将数据导入Excel,将Excel中的数据导入数据库的功能,曾经也查找过相关的内容,将曾经用过的方案总结一下. 方案一 NPOI NPOI 是 POI 项目的 .NET 版本.POI ...

  6. sqlserver 中数据导入到mysql中的方法以及注意事项

    数据导入从sql server 到mysql (将数据以文本格式从sqlserver中导出,注意编码格式,再将文本文件导入mysql中): 1.若从slqserver中导出的表中不包含中文采用: bc ...

  7. 数据分析(7):pandas介绍和数据导入和导出

    前言 Numpy Numpy是科学计算的基础包,对数组级的运算支持较好 pandas pandas提供了使我们能够快速便捷地处理结构化数据的大量数据结构和函数.pandas兼具Numpy高性能的数组计 ...

  8. MySQL学习笔记十一:数据导入与导出

    数据导入 1.mysqlimport命令行导入数据 在使用mysqlimport命令导入数据时,数据来源文件名要和目标表一致,不想改文件名的话,可以复制一份创建临时文件,示例如下. 建立一个文本use ...

  9. geotrellis使用(十二)再记录一次惨痛的伪BUG调试经历(数据导入以及读取瓦片)

    Geotrellis系列文章链接地址http://www.cnblogs.com/shoufengwei/p/5619419.html 目录 前言 BUG还原 查找BUG 解决方案 总结 后记 一.前 ...

随机推荐

  1. SharePoint 2013 Create Folder with conententtype programer

    记录一下昨天写的SharePoint tool,需求是这样的: 在SharePoint list subfolder 下创建1000个folder,这些folder指定特殊的contenttype,c ...

  2. Eureka参数配置->Server端参数

    1.基本参数 参数 默认值 说明 eureka.server.enable-self-preservation true 是否开启自我保护模式 eureka.server.renewal-percen ...

  3. jenkins+svn+Ant+tomcat+非maven项目构建

    首先,输入项目名称,创建一个自由风格的项目; 然后,配置旧项目的策略参数,目的是防止构建项目太多,占用资源. 下一步,jdk版本选择: 下一步,关联svn项目. 下一步:配置ant 看不清,再来一张. ...

  4. WCF尝试创建与发布IIS(含问题描述)

    技术贴技术贴就直接讲技术来,客套的话我也不多说了,各位看官包涵包涵. 跟着园内高手一步一步发布成功,欣喜若狂之际,发个贴纪念纪念一下. 废话不多说,不正确之处,还望大家积极指出,共同进步.哈哈~~~ ...

  5. 一个原生JS实现的不太成熟的贪吃蛇游戏

    一个初初初初级前端民工 主要是记录一下写过的东西,复习用 大佬们如果看到代码哪里不符合规范,或者有更好写法的,欢迎各位批评指正 十分感谢 实现一个贪吃蛇游戏需要几步? 1.有地图 2.有蛇 3.有食物 ...

  6. scalikejdbc 学习笔记(3)

    重用connection: package com.citi.scalikejdbc import scalikejdbc._ import scalikejdbc.config._ object C ...

  7. .Net Core删除ClientApp目录,重新生成报错解决办法

    因为在老的项目上做修改,需要删除单独的spa目录,就把ClientApp删掉了.但是重新生成报错,在VS2017界面上也没找到在什么地方配置.最后发现在csproj上里面可以去掉spa的配置 < ...

  8. 可能是国内第一篇全面解读 Java 现状及趋势的文章

    作者 | 张晓楠 Dragonwell JDK 最新版本 8.1.1-GA 发布,包括全新特性和更新! 导读:InfoQ 发布<2019 中国 Java 发展趋势报告>,反映 Java 在 ...

  9. 移动端的<meta>标签

    <head> <meta charset="UTF-8" /> <!-- 页面关键词 --> <meta name="keywo ...

  10. python编程基础之三十一

    面向对象:一开始接触面向对象其实感觉不好用,但是对于一些复杂的问题,使用面向对象其实更加容易,逻辑不容易混乱 它的核心是:类 和 对象 类:对一系列事物的抽象概念,可以视为一张图纸, 对象:就是对类这 ...