[MonetDB-users] "Copy into ... from STDIN" end of file
Hi, I'm trying to load data using copy command and STDIN source in command line but the process ends without waiting for records. I think this is first step to load data from a second process without using file source. Here is the command: mclient -l sql -d database -u user -P pwd -s "COPY INTO table FROM STDIN" It returns immediately with exit code 0. With postgresql, the "same" command (psql -U user -h host database -c "\copy table from STDIN") prompt for datas and wait until antislash-dot ("\.") input ends records so it allows a process to load datas using STDIN. Do you think this is possible with mclient sql copy command? Regards, Matthieu
Hi,
I'm trying to load data using copy command and STDIN source in command line but the process ends without waiting for records. I think this is first step to load data from a second process without using file source.
Here is the command: mclient -l sql -d database -u user -P pwd -s "COPY INTO table FROM STDIN" It returns immediately with exit code 0.
As far as I know, the "STDIN" input specifier for the "COPY" command refers to the stream where the SQL command came from, and not necessarily standard input. So in your case, the records are expected in the "-s" option argument. I was able to insert records like this: mclient -l sql -d database -u user -P pwd -s "COPY 5 RECORDS INTO some_table FROM STDIN USING DELIMITERS ',','\n';1,2,3 4,5,6 7,8,9 10,11,12 13,14,15 " This thread was rather useful for me to get started with the "COPY" command: [1]. This behaviour for "STDIN" might seem awkward when encountering it for the first time, but it becomes very useful when using Mapi directly without mclient.
With postgresql, the "same" command (psql -U user -h host database -c "\copy table from STDIN") prompt for datas and wait until antislash-dot ("\.") input ends records so it allows a process to load datas using STDIN.
Do you think this is possible with mclient sql copy command?
I haven't tried, but you might be able to emulate something similar by specifying a named pipe as the data source. Best regards, Isidor Zeuner [1] http://article.gmane.org/gmane.comp.db.monetdb.user/1517/match=copy+records+...
Hi,
I haven't tried, but you might be able to emulate something similar by specifying a named pipe as the data source. It works :) Thanks for the tip!
Matthieu PS: Sorry for such linux user base questions, there was no link with MonetDB Le 08/04/2010 23:48, Isidor Zeuner a écrit :
Hi,
I'm trying to load data using copy command and STDIN source in command line but the process ends without waiting for records. I think this is first step to load data from a second process without using file source.
Here is the command: mclient -l sql -d database -u user -P pwd -s "COPY INTO table FROM STDIN" It returns immediately with exit code 0.
As far as I know, the "STDIN" input specifier for the "COPY" command refers to the stream where the SQL command came from, and not necessarily standard input. So in your case, the records are expected in the "-s" option argument. I was able to insert records like this:
mclient -l sql -d database -u user -P pwd -s "COPY 5 RECORDS INTO some_table FROM STDIN USING DELIMITERS ',','\n';1,2,3 4,5,6 7,8,9 10,11,12 13,14,15
"
This thread was rather useful for me to get started with the "COPY" command: [1].
This behaviour for "STDIN" might seem awkward when encountering it for the first time, but it becomes very useful when using Mapi directly without mclient.
With postgresql, the "same" command (psql -U user -h host database -c "\copy table from STDIN") prompt for datas and wait until antislash-dot ("\.") input ends records so it allows a process to load datas using STDIN.
Do you think this is possible with mclient sql copy command?
I haven't tried, but you might be able to emulate something similar by specifying a named pipe as the data source.
Best regards,
Isidor Zeuner
[1] http://article.gmane.org/gmane.comp.db.monetdb.user/1517/match=copy+records+...
------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ MonetDB-users mailing list MonetDB-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/monetdb-users
Hi!
I haven't tried, but you might be able to emulate something similar by specifying a named pipe as the data source. It works :) Thanks for the tip!
Good to hear. Thanks for sharing!
Matthieu PS: Sorry for such linux user base questions, there was no link with MonetDB
Well, I think that post was actually kind of valuable, because (a) to my knowledge it is not documented that sequential access to the data file is sufficient for using "COPY", and (b) this use case might provide a clue about a two-stream (one command stream and one data stream) loading interface being desirable in the case that sequential access will go away some day (should there be a test script to guard this?). Best regards, Isidor
participants (2)
-
Isidor Zeuner
-
Matthieu Guamis