I want to execute queries which are stored in text file on OrientDB console.
I am currently referring to https://github.com/sslavic/orientdb-wiki/blob/master/Console-Commands.md Batch Mode, but getting unrecognized command error.
from the terminal you must go in the folder "bin" of your version of OrientDb
and you must give the command console.bat path of your file.txt
I've tryed with the last snapshot and i've no problem with this console command.
In your file.txt make sure you dont miss any semicolon, probably you have some parsing problem in your file or any othter sintaxt/typo issue, so orient can not find a suitable command for some string, dont know if you can post your code.. but at least update with the full console output.
Related
I have to copy few postgres table contents into a CSV file for further processing using Talend.
When I tried
copy table_name to ‘/tmp/export/table_name.csv’ with CSV;
with 'tpostgresqlRow' component, it threw error saying "Need superuser access", which I wouldn't be getting.
As an alternative, I tried "\copy" command as
\\copy table_name to ‘/tmp/export/table_name.csv’ with CSV;"
(first slash is used to escape the other). Still it threw error saying "Syntax error at '\'".
I tried with tpostgresqlBulkExec component as well, which internally uses "copy" command, and it as well threw error saying "Need superuser access".
Is there a way out to execute this postgres "copy" command in bulk using Talend?
Any help would be much appreciated.
The copy command needs access to both the postgres table and the local file system.
I think your problem is caused because you do not have access to the local folder. you need to sort that out, or try a different folder that you know you have access to.
with the same user, if you try linux command
touch /tmp/export/test.csv
you may see an error.
the \copy command will fail because to use that you first need to be using a tool called psql.
I got confirmation from Talend Support Team that tPostgresqlRow component would not support 'COPY' command. I have resolved my case by installing PSQL client and calling the same using tSSH component in Talend to execute the desired 'COPY' commands.
I have written a simple batch script which loops a directory and echoes some details about each file.When I view its results in the CMD terminal or output it to some file, I can view the results as expected.
The problem comes with PostgreSQL: when I try to import its results into a table, executing the following command:
copy schema.table(field) from program 'C:\\...\\my_bat.bat' with CSV header delimiter E'\t';
It imports 0 results, whereas if I run the same command pointing to a similar batch file in another directory, it works as expected.
What's going on? I am using windows.
Update: I have tried running the copy command calling program again on another batch script and this time, only a part of the string output is being imported.
The service user postgres needs sufficient permissions to run the program.
I remember that it was hard to change settings for that account on windows XP, I have not tried on more recent windows - service users are hidden by most GUI tools.
I'm using MongoDB version 3.0 and I want to run script.js on database
Problem I have find is that mongo is not seeing my file script.js.
What I have done step by step:
I have installed MongoDB in directory MongoDB\Server\3.0\bin\
I have put script.js inside \bin directory
I want to do is run script.js using load() method
I have got an error
load("script.js")
2016-10-09T22:17:17.557+0200 E - file [script.js] doesn't exist
2016-10-09T22:17:17.558+0200 E QUERY Error: error loading js file: script.js
at (shell):1:1
Probably I have put script.js in wrong place but where I should put it?
Next step is I'm using mlab and I want to load my script to the online server, how to do this?
I don't know of any magic that would make a \bin directory relevant, but assuming that your script is located in /bin, you just need to call out the full path when you do the load from within the mongoshell
load('/bin/script.js');
If your script is located off your home directory it will be like
load('/Users/yourname/script.js');
See the docs for load: https://docs.mongodb.com/manual/reference/method/load/
Ditto for how you run it on "the server". Its not so much running on the server, but in the shell that you are running. If the shell is connected to a particular server, the effects of the script will be on the server but the script itself executes in your shell.
For windows try:
load('c:\MongoDB\Server\3.0\bin\prova.js')
load("C:\\Data\\Mongo\\M001\\loadMovieDetailsDataset\\loadMovieDetailsDataset.js")
Double \ does the trick. I was receiving similar error as my install path was not set and the file res
Try changing the name of the .js file. In my case, the error was coming because the folder name and the file name were the same.
Basically I am just trying to create a batch file to copy one file from one location to another location in Windows XP like the code below but failed. May I know why?
copy C:/Directory_A/the_file D:/Directory_B
When I execute the batch file I see this in the output:
The syntax of the command is incorrect.
Try using backslashes
copy C:\Directory_A\the_file D:\Directory_B
I am running this command in powershell:
sqlplus system/passwd#mydb #my_sql
I have tried it with and without backticks and various other versions I found via Google. I keep getting an error when the command is passed off to sqlplus and have been unsucessful in finding the fix. Hopefully someone here can help out?
The error I get is:
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SP2-0042: unknown command " ■#" - rest of line ignored.
So I am sucessfully connecting to the database but there is an extra character being passed to sqlplus in front of the '#'. " ■#" in notepad++ looks like " ¦#"
If you created your SQL command file using a redirect (> or >>) in powershell - like:
myProgram > mySQL.out
and then run it like:
&sqlplus mypw/myuser#mydb.xyz.com "#mySQL.out"
Powershell may have saved the output file in UTF-16 format, which Sqlplus does not like.
(You can confirm by creating the exact same file by hand and then comparing it - byte count will be off and in KDiff you'll get message to the effect that the text is equal, but the files are not binary equal).
To fix - you need to do two things: :
Add some blank lines to the top of your SQL commands - Powershell will still write a BOM (Byte Order Mark) there and it looks like it's pretty hard to get it to avoid that - but sqlplus will just go by it, albeit giving an error - but will move on to the rest of your code OK.
And then run this command in powershell before creating your file: $PSDefaultParameterValues['Out-File:Encoding'] = 'utf8'
See Changing PowerShell's default output encoding to UTF-8
I received this error:
SP2-0042: unknown command " ■S" - rest of line ignored.
and this fixed that - or at least I was able to run it. You can also just cut and past it from one window into another using Notepad++ and that will solve the BOM and encoding issue.
Update Problem Solved. This turned out being "not seeing the trees through the forest". I have been using these sql scripts for several years without issue called from a bash script. When I tried converting the bash script to powershell and ran into issues I blamed it on powershell. However; it turned out there was something corrupt in the sql file itself. There were no obvious errors when looking at the file in notepad++ even with show all symbols clicked and it was ANSI format. I determined it was the sql file itself when I manually ran sqlplus from a cmd window I still had the same error I was getting with powershell. I rewrote the script and saved it and the problem was fixed. I should have manually ran the script on day one and I probably could have resolved sooner.
I had the same problem. My issue was caused because the script file was saved as unicode. I don't know if this will help you or not, but here is how I fixed it:
Edit the script with notepad. Click File -> Save As. Change type from Unicode (or whatever) to ANSI, and save.
A couple of suggestions
Try the invoke operator:
&sqlplus system/passwd#mydb #my_sql
Try start-process:
start-process -NoNewWindow -FilePath sqlplus -ArgumentList #"
system/passwd#mydb #my_sql
"#
I had typical problem. The message was:
unknown command "and" - rest of line ignored.
The reason was an empty string in code.
e.g.
select ...
from ...
where ...
[empty string]
and ... < here was an error message
use as following
sqlplus -s system/passwd#mydb "#my_sql";