用于删除数据库(如果存在)并在OrientDB中创建新数据库的命令

用于删除数据库(如果存在)并在OrientDB中创建新数据库的命令,orientdb,Orientdb,我想写一个脚本,它将在OrientDB控制台上运行。脚本需要删除数据库(如果存在)并创建新的数据库 我正在使用以下命令: drop database remote:localhost/testgraphdb1 root xyz create database remote:localhost/testgraphdb1 root xyz local graph; 如何避免命令尝试删除不存在的数据库时发生错误。可能使用try/catch块 try{ drop database remot

我想写一个脚本,它将在OrientDB控制台上运行。脚本需要删除数据库(如果存在)并创建新的数据库

我正在使用以下命令:

drop database remote:localhost/testgraphdb1 root xyz

create database remote:localhost/testgraphdb1 root xyz local graph;

如何避免命令尝试删除不存在的数据库时发生错误。

可能使用
try/catch

try{
    drop database remote:localhost/testgraphdb1 root xyz
}catch(e){
// Print ?
}
create database remote:localhost/testgraphdb1 root xyz local graph;

我也在OrientDB论坛上提出了这个问题。此功能(如果存在,则删除数据库)不存在。将为此创建一个新的功能请求,希望很快就能实现

我使用相同的“console.sh myscript.sql”执行过程,遇到了相同的问题。我的搜索将我带到了这里,并跟进了为OrientDB创建的问题。截至撰写本文时,未对其进行处理。我的解决方案是在myscript.sql文件中包装drop语句,如下所示:

set ignoreErrors true;
drop database remote:localhost/testgraphdb1 root xyz;
set ignoreErrors false;

create database remote:localhost/testgraphdb1 root xyz local graph;

我不知道您使用哪种语言,这取决于catch可能是什么语言:
catch(异常e)
它给出了以下错误:OrientDB console v.1.6.4(buildUNKNOWN@r;2014-01-16 00:01:20+0100)www.orientechnologies.com键入“help”以显示所有支持的命令。安装GREMLIN语言v.2.5.0-SNAPSHOT的扩展!无法识别的命令:“try{'What's language?
GREMLIN
?我正在编写一个脚本,它将在OrientDB console.sh上运行。可能是这样。下面是功能请求:查看下面TimH的解决方案,了解简单的解决方法。