Importing data into singlestore db using csv - database

I am new to MEMSQL and trying to restore data into MEMSQL db using .csv file but its below error
ERROR 1017 ER_FILE_NOT_FOUND: Can’t find file: ‘\home\vagrant\filename.csv’ (errno: 2)
CSV data is imported from another server.
I have memsql on virtual machine.
I have copied table dump csv to \home\vagrant\ location.
I am trying below command to restore data.
LOAD DATA INFILE ‘\home\vagrant\filename.csv’ INTO TABLE “tableName” FIELDS TERMINATED BY ‘\t’ LINES TERMINATED BY ‘\n’;
Thanks in advance

Just to clarify, the filename.csv file is located inside the virtual machine running memsql or is located on same machine your running the LOAD DATA from?
If the file is on the same machine your running LOAD DATA from you need to add the LOCAL keyword (LOAD DATA LOCAL INFILE ...)

Related

restoring a mbz5g4 file from sql anywhere

I have an mbz5g4 file that contains a database dump of micros POS DB and i would like to visualize the data(tables) in this file I have SQL anywhere, is there a way to attach the file to my local DB so I could visualize it and eventually export it as CSV

How to load data from UNIX to snowflake

I have created CSV files into UNIX server using Informatica resides in. I want to load those CSV files directly from UNIX box to snowflake using snowsql, can someone help me how to do that?
Log into SnowSQL:
https://docs.snowflake.com/en/user-guide/getting-started-tutorial-log-in.html
Create a Database, Table and Virtual Warehouse, if not done so already:
https://docs.snowflake.com/en/user-guide/getting-started-tutorial-create-objects.html
Stage the CSV files, using PUT:
https://docs.snowflake.com/en/user-guide/getting-started-tutorial-stage-data-files.html
Copy the files into the target table using COPY INTO:
https://docs.snowflake.com/en/user-guide/getting-started-tutorial-copy-into.html

Oracle RDS (AWS): How to retrieve files generated?

Here's the situation, we have a store procedure that generates .txt files in a directory inside of a database. I recently migrated from Oracle DB SE on Linux to an RDS oracle database instance.
I know I'm not able to access files remotely (no scp, or sftp) to copy the files that it generates, so instead of I decided to use DBMS_FILE_TRANSFER.PUT_FILE using a DB link to another database.
The link is working fine, but whenever I try to copy the file I get the following error:
ERROR at line 1:
ORA-19505: failed to identify file "/u01/test.txt"
ORA-27046: file size is not a multiple of logical block size
Additional information: 1
Is there any alternatives to do this without using an EC2 instance?
File size must be a multiple of 512 (or whatever you've set the logical block size to)
Ensure when the file is made that the size is exactly a multiple of 512, pad with zeros or similar to ensure this
See https://asktom.oracle.com/pls/apex/asktom.search?tag=file-transfer

How to use SQL loader when loading from remote data file?

I am trying to load data in Oracle database from BCP files.
The Oracle database server is located on remote machine. In my control file I have added path to BCP file as - load data INFILE 'C:\path\to\bcpFile.txt'. This does not work if BCP files are not on same machine as DB server. One option I found is to create network mapping on my windows machine to the linux DB server. But this has manual overhead. I learned we can use LOAD DATA LOCAL INFILE to fetch data files, I would like see an example for this.
Install the full Oracle Client which includes SQL Loader on your Windows Computer
SQL Loader is included with full Oracle Client installs.
Once installed, make sure your infile section properly references your datafile using the correct syntax.
With the path you provided, this section would look like this:
INFILE 'C:\path\to\bcpFile.txt'

SQL Server Bulk Insert fails (Network related)

I'm fairly new to SQL Server.
I'm trying to bulk insert into a table, using the command in SQL Server Management Studio (2005):
BULK INSERT Table1 FROM 'c:\text.txt' WITH (FIELDTERMINATOR = '|')
I get the error:
Msg 4860, Level 16, State 1, Line 1
Cannot bulk load. The file "c:\text.txt" does not exist.
I'm positive the file actually exists.
I get the feeling that it is looking for the file on the local hard drive for where ever the server is. Is that the case? If so, how do you generally solve this problem? (to note, I've tried specifying the network address of my PC when entering the location of the text file, but I get a permission error. Also, I know in advance that my company doesn't allow files to placed on a server).
SQL Server does not have an SQL statement that reads data from the client end (as the other posters have pointed out). Other RDBMS products do implement this (eg. the Postgres COPY statement lets you specify a file on the server or a file on the client that is read by the db connectivity library on the client side).
You can achieve moving data from a file on the client to a table on SQL Server using the bcp command line program.
bcp lets you copy data from a local file to a table on the server, or from a table (or select query) on the server into a local file. For example:
bcp servername.dbname.tablename in c:\temp.txt -T -c
will copy a tabbed delimited file (temp.txt) into the specified table (assuming the file contains the right number of columns).
I am not sure if this helps, but it is the only way to move data from a client file to a server table without giving the server some sort of access across the network to the data file on client.
I'd agree that it's a problem with the file being on your C drive, and not the server's drive.
If it's a permissions issue, have you tried creating a file share on your workstation that the server does have permissions to read from? Maybe something like \YourWorkstation\SQLFile, and then granting everyone (or Guest, depending on how your network permissions are set up) read access on it?
If you can't create the share on your laptop, or you can't grant rights to it for some reason, is there a file share somewhere in the office that you do have rights to, and that SQL can also read from? Maybe a NAS or a "Common" network folder?
Have you created a share drive on your machine that the server can see? If so then you just need to refer to the path including your machine name instead of C:
Yes, it will look for the file on the SQL server itself.
If you can map a network drive to the C drive of your SQL server, then you can just copy the file over before running the bulk insert.
If you absolutely can't get any access to the server's file system, then you can look at doing something like this:
write a program that reads your text file and inserts the contents into single record in a temporary table that has a Text field, perhaps using a stored procedure
have the program execute the bcp command to export the data from the temporary table into a text file on the SQL server's local file system, to a folder that the account under which the SQL service is running has write permission
have the program run a bulk insert command specifying the path to the text file on the server
delete the text file and the temporary table

Resources