failed to open file when 'copy binary into table from binaryformfile'
hi all, when i use the command in sql: sql>copy binary into testtable from('file1'); failed to open file file1 the file1 contents : [svomhpc@localhost /home/data1]$>cat file1 0123[svomhpc@localhost /home/data1]$>hexdump file1 0000000 0000 3000 0000 3100 0000 3200 0000 3300 0000010 can anyone tell me what's wrong with file1 or how to use copy binary with? Meng
COPY INTO requires absolute path(s) of the file(s): from http://www.monetdb.org/Documentation/Manuals/SQLreference/CopyInto : "The file read from should be accessible by the server and must use an absolute path name." from "The 'file' should be an SQL string that contains the absolute path name of the file to be inserted. The file is read directly by the server, and so has to be accessible to the server." from http://www.monetdb.org/Documentation/Cookbooks/SQLrecipes/BinaryBulkLoad : "The file names must be absolute paths to the columns files. They should reside on the same file system as the database farm" Stefan ----- Original Message -----
hi all,
when i use the command in sql:
sql>copy binary into testtable from('file1'); failed to open file file1
the file1 contents : [svomhpc@localhost /home/data1]$>cat file1 0123[svomhpc@localhost /home/data1]$>hexdump file1 0000000 0000 3000 0000 3100 0000 3200 0000 3300 0000010
can anyone tell me what's wrong with file1 or how to use copy binary with?
Meng _______________________________________________ users-list mailing list users-list@monetdb.org http://mail.monetdb.org/mailman/listinfo/users-list
-- | Stefan.Manegold@CWI.nl | DB Architectures (DA) | | www.CWI.nl/~manegold/ | Science Park 123 (L321) | | +31 (0)20 592-4212 | 1098 XG Amsterdam (NL) |
Indeed. Thanks! Fixed. ----- Original Message -----
On 17.07.2013, at 08:04, Stefan Manegold
wrote: They should reside on the same file system as the database farm" This one is actually a "must".
Best
Hannes
_______________________________________________ users-list mailing list users-list@monetdb.org http://mail.monetdb.org/mailman/listinfo/users-list
-- | Stefan.Manegold@CWI.nl | DB Architectures (DA) | | www.CWI.nl/~manegold/ | Science Park 123 (L321) | | +31 (0)20 592-4212 | 1098 XG Amsterdam (NL) |
Thanks very much, it works!
Still i want to know can i use COPY INTO FILE like "copy select * from
sys.testtable into '/home/data1/file2'; "
to copy into file in a binary form?
because i want to use COPY BINARY INTO tablename, but i dont know how to
write the result set of float and double binary into a file first.
Meng
2013/7/17 Stefan Manegold
Indeed. Thanks! Fixed.
----- Original Message -----
On 17.07.2013, at 08:04, Stefan Manegold
wrote: They should reside on the same file system as the database farm" This one is actually a "must".
Best
Hannes
_______________________________________________ users-list mailing list users-list@monetdb.org http://mail.monetdb.org/mailman/listinfo/users-list
-- | Stefan.Manegold@CWI.nl | DB Architectures (DA) | | www.CWI.nl/~manegold/ | Science Park 123 (L321) | | +31 (0)20 592-4212 | 1098 XG Amsterdam (NL) |
_______________________________________________ users-list mailing list users-list@monetdb.org http://mail.monetdb.org/mailman/listinfo/users-list
No, MonetDB currently does not support binary copy into file. You might want to file a feature request for this via http://bugs.monetdb.org/ Stefan ----- Original Message -----
Thanks very much, it works!
Still i want to know can i use COPY INTO FILE like "copy select * from sys.testtable into '/home/data1/file2'; " to copy into file in a binary form? because i want to use COPY BINARY INTO tablename, but i dont know how to write the result set of float and double binary into a file first.
Meng
2013/7/17 Stefan Manegold
Indeed. Thanks! Fixed.
----- Original Message -----
On 17.07.2013, at 08:04, Stefan Manegold
wrote: They should reside on the same file system as the database farm" This one is actually a "must".
Best
Hannes
_______________________________________________ users-list mailing list users-list@monetdb.org http://mail.monetdb.org/mailman/listinfo/users-list
-- | Stefan.Manegold@CWI.nl | DB Architectures (DA) | | www.CWI.nl/~manegold/ | Science Park 123 (L321) | | +31 (0)20 592-4212 | 1098 XG Amsterdam (NL) |
_______________________________________________ users-list mailing list users-list@monetdb.org http://mail.monetdb.org/mailman/listinfo/users-list
_______________________________________________ users-list mailing list users-list@monetdb.org http://mail.monetdb.org/mailman/listinfo/users-list
-- | Stefan.Manegold@CWI.nl | DB Architectures (DA) | | www.CWI.nl/~manegold/ | Science Park 123 (L321) | | +31 (0)20 592-4212 | 1098 XG Amsterdam (NL) |
then when i want to COPY BINARY INTO table, how to write to float into a
file in the binary form first?
2013/7/17 Stefan Manegold
No, MonetDB currently does not support binary copy into file. You might want to file a feature request for this via http://bugs.monetdb.org/
Stefan
----- Original Message -----
Thanks very much, it works!
Still i want to know can i use COPY INTO FILE like "copy select * from sys.testtable into '/home/data1/file2'; " to copy into file in a binary form? because i want to use COPY BINARY INTO tablename, but i dont know how to write the result set of float and double binary into a file first.
Meng
2013/7/17 Stefan Manegold
Indeed. Thanks! Fixed.
----- Original Message -----
On 17.07.2013, at 08:04, Stefan Manegold
wrote: They should reside on the same file system as the database farm" This one is actually a "must".
Best
Hannes
_______________________________________________ users-list mailing list users-list@monetdb.org http://mail.monetdb.org/mailman/listinfo/users-list
-- | Stefan.Manegold@CWI.nl | DB Architectures (DA) | | www.CWI.nl/~manegold/ | Science Park 123 (L321) | | +31 (0)20 592-4212 | 1098 XG Amsterdam (NL) |
_______________________________________________ users-list mailing list users-list@monetdb.org http://mail.monetdb.org/mailman/listinfo/users-list
_______________________________________________ users-list mailing list users-list@monetdb.org http://mail.monetdb.org/mailman/listinfo/users-list
-- | Stefan.Manegold@CWI.nl | DB Architectures (DA) | | www.CWI.nl/~manegold/ | Science Park 123 (L321) | | +31 (0)20 592-4212 | 1098 XG Amsterdam (NL) |
_______________________________________________ users-list mailing list users-list@monetdb.org http://mail.monetdb.org/mailman/listinfo/users-list
from http://www.monetdb.org/Documentation/Cookbooks/SQLrecipes/BinaryBulkLoad " Each attachment file is produced by a program that writes the binary image of the BAT directly, i.e. a binary dump of an C-array. For the SQL types char (1 byte), tinyint (8-bits), smallint (16-bits), int/integer (32 bits), and bigint (64 bits) correspond with the C types directly; real and double are mapped onto type float and double in C, respectively. " i.e., your data source write a respective C array to a file. Stefan ----- Original Message -----
then when i want to COPY BINARY INTO table, how to write to float into a file in the binary form first?
2013/7/17 Stefan Manegold
No, MonetDB currently does not support binary copy into file. You might want to file a feature request for this via http://bugs.monetdb.org/
Stefan
----- Original Message -----
Thanks very much, it works!
Still i want to know can i use COPY INTO FILE like "copy select * from sys.testtable into '/home/data1/file2'; " to copy into file in a binary form? because i want to use COPY BINARY INTO tablename, but i dont know how to write the result set of float and double binary into a file first.
Meng
2013/7/17 Stefan Manegold
Indeed. Thanks! Fixed.
----- Original Message -----
On 17.07.2013, at 08:04, Stefan Manegold
wrote: They should reside on the same file system as the database farm" This one is actually a "must".
Best
Hannes
_______________________________________________ users-list mailing list users-list@monetdb.org http://mail.monetdb.org/mailman/listinfo/users-list
-- | Stefan.Manegold@CWI.nl | DB Architectures (DA) | | www.CWI.nl/~manegold/ | Science Park 123 (L321) | | +31 (0)20 592-4212 | 1098 XG Amsterdam (NL) |
_______________________________________________ users-list mailing list users-list@monetdb.org http://mail.monetdb.org/mailman/listinfo/users-list
_______________________________________________ users-list mailing list users-list@monetdb.org http://mail.monetdb.org/mailman/listinfo/users-list
-- | Stefan.Manegold@CWI.nl | DB Architectures (DA) | | www.CWI.nl/~manegold/ | Science Park 123 (L321) | | +31 (0)20 592-4212 | 1098 XG Amsterdam (NL) |
_______________________________________________ users-list mailing list users-list@monetdb.org http://mail.monetdb.org/mailman/listinfo/users-list
_______________________________________________ users-list mailing list users-list@monetdb.org http://mail.monetdb.org/mailman/listinfo/users-list
-- | Stefan.Manegold@CWI.nl | DB Architectures (DA) | | www.CWI.nl/~manegold/ | Science Park 123 (L321) | | +31 (0)20 592-4212 | 1098 XG Amsterdam (NL) |
Hai Meng, As I have already mentioned in my earlier e-mails, you need to extend your C-code to write your binary data to files, one file per column. E.g., change writeToDBBinary() to do the following steps: 0. create a strBuf for every column, and add data per column. (your existing code add data per row). 1. fopen() open a file for writing one column. 2. fwrite() to write each strBuf to the corresponding file 3. fclose() all open files 4. execute "COPY BINARY INTO" query You can find the exact usages of these function from their MAN pages, or any C-programming text books, or Baidu. Regards, Jennie On Jul 17, 2013, at 10:02, Angelasweet wrote:
then when i want to COPY BINARY INTO table, how to write to float into a file in the binary form first?
2013/7/17 Stefan Manegold
No, MonetDB currently does not support binary copy into file. You might want to file a feature request for this via http://bugs.monetdb.org/ Stefan
----- Original Message -----
Thanks very much, it works!
Still i want to know can i use COPY INTO FILE like "copy select * from sys.testtable into '/home/data1/file2'; " to copy into file in a binary form? because i want to use COPY BINARY INTO tablename, but i dont know how to write the result set of float and double binary into a file first.
Meng
2013/7/17 Stefan Manegold
Indeed. Thanks! Fixed.
----- Original Message -----
On 17.07.2013, at 08:04, Stefan Manegold
wrote: They should reside on the same file system as the database farm" This one is actually a "must".
Best
Hannes
_______________________________________________ users-list mailing list users-list@monetdb.org http://mail.monetdb.org/mailman/listinfo/users-list
-- | Stefan.Manegold@CWI.nl | DB Architectures (DA) | | www.CWI.nl/~manegold/ | Science Park 123 (L321) | | +31 (0)20 592-4212 | 1098 XG Amsterdam (NL) |
_______________________________________________ users-list mailing list users-list@monetdb.org http://mail.monetdb.org/mailman/listinfo/users-list
_______________________________________________ users-list mailing list users-list@monetdb.org http://mail.monetdb.org/mailman/listinfo/users-list
-- | Stefan.Manegold@CWI.nl | DB Architectures (DA) | | www.CWI.nl/~manegold/ | Science Park 123 (L321) | | +31 (0)20 592-4212 | 1098 XG Amsterdam (NL) |
_______________________________________________ users-list mailing list users-list@monetdb.org http://mail.monetdb.org/mailman/listinfo/users-list
_______________________________________________ users-list mailing list users-list@monetdb.org http://mail.monetdb.org/mailman/listinfo/users-list
participants (5)
-
Angelasweet
-
Hannes Mühleisen
-
integrity
-
Stefan Manegold
-
Ying Zhang