Command for dropping the database if it exists and create new one in OrientDB

StackOverflow https://stackoverflow.com/questions/21730598

  •  10-10-2022
  •  | 
  •  

Frage

I want to write a script which will be run on OrientDB Console. The script needs to delete the database if it exists and create new one.

I am using following commands:

drop database remote:localhost/testgraphdb1 root xyz

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

How can I avoid the error occurred when the command tries to drop a database which doesn't exist.

War es hilfreich?

Lösung 2

I had put this question on the OrientDB forum also. This feature (drop database if exists) doesn't exist. A new feature request will be created for this and hopefully this will be implemented soon.

https://groups.google.com/forum/#!topic/orient-database/nvW6vZmUk6k

Andere Tipps

I use the same "console.sh myscript.sql" execution process and ran into the same issue. My search led me here and I followed up on the issues created for OrientDB. They are not addressed as of this writing. My solution was to do wrap the drop statement in the myscript.sql file as such:

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

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

Maybe use a try/catch block?

try{
    drop database remote:localhost/testgraphdb1 root xyz
}catch(e){
// Print ?
}
create database remote:localhost/testgraphdb1 root xyz local graph;
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top