load-data-infile

Switching from MySQL to PostgreSQL - tips, tricks and gotchas?

三世轮回 提交于 2019-11-29 18:48:53
I am contemplating a switch from MySQL to PostgreSQL. What are your tips, tricks and gotchas for working with PostgreSQL? What should a MySQLer look out for? See also: How different is PostgreSQL to MySQL? See also: Migrate from MySQL to PostgreSQL Note - I don't think this is a duplicate. In particular the type of answers are quite diffferent and the responses here have much more implementation detail, which is what I was looking for rfusca Just went through this myself, well I still am... Case sensitive text Lack of INSERT IGNORE and REPLACE Explicit casting needed almost everywhere No

MySQL LOAD DATA INFILE store line number

≯℡__Kan透↙ 提交于 2019-11-29 17:21:39
I'm using MySQL LOAD DATA INFILE to move CSV file data into a database table. I'm looking for a way to reference the original file line number (row) in the imported record. So that a table like this: CREATE TABLE tableName ( uniqueId INT UNSIGNED NOT NULL PRIMARY_KEY, import_file VARCHAR(100), import_line INT, import_date = DATETIME, fieldA VARCHAR(100), fieldB VARCHAR(100), fieldC VARCHAR(100) ); Where import_file,import_line and import data are meta data relevant to the specific file import. fieldA, fieldB and fieldC represent the actual data in the file. Would be updated by a query like

Trying to do LOAD DATA INFILE with REPLACE and AUTO_INCREMENT

不问归期 提交于 2019-11-29 11:40:07
问题 I am trying to load a file onto a MySQL database, having the primary key auto_incremented and I would like the data to be updated if i find any duplicate rows. However, the REPLACE keywords only works on primary key, which is auto generated so i'm stuck. how to be able to have a table with an ID that auto_increments and at the same time to be able to insert/update data from a file using LOAD DATA INFILE? Here is the table CREATE TABLE `oxygen_domain`.`TEST` ( `TEST_ID` int(11) NOT NULL AUTO

MySQL LOAD DATA Error (Errcode: 2 - “No such file or directory”)

笑着哭i 提交于 2019-11-29 11:12:43
I am trying to load data into a table of my MySQL database, and getting this error. LOAD DATA LOCAL INFILE 'C:\Users\Myself\Desktop\Blah Blah\LOAD DATA\week.txt' INTO TABLE week; Reference: this The path is hundred percent correct, I copied it by pressing shift and clicking "copy path as" and checked it many times. So any tips on this will be much appreciated . . My research: Seeing this answer, I tried by changing C:\Users to C:\\Users . It did not work for me. Secondly, is there a way to use some kind of a relative path (rather than an absolute path) here? I don't know what version of MySQL

Tool for importing CSV files into MySQL database? [closed]

泄露秘密 提交于 2019-11-29 08:47:33
I've got several CSV files I want to import into a table. They all contain different numbers of columns, so some data will be absent during each import. I need a tool that will let me map which CSV column goes into which MySQL column. Doesn't look like MySQL workbench can do this. What else can I use? MySQL has the LOAD DATA INFILE syntax: LOAD DATA INFILE 'data.txt' INTO TABLE tbl_name FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\r\n' IGNORE 1 LINES; See the documentation about custom data handling. jranz If you're running on a Mac, Sequel Pro is pretty good for this sort of

Why can't I use LOAD DATA LOCAL with PDO even though I can from cli client?

与世无争的帅哥 提交于 2019-11-29 05:14:11
I recently upgraded my Ubuntu 10.04 dev server to 14.04. It is actually a fresh install. PHP version was 5.4.15, and is now PHP 5.5.9. MySQL went from 5.1.67 to 5.5.37. I am trying to LOAD LOCAL DATA INFILE on a new server. It works running the command using the local mysql cli client. It does not work when executing using PDO: PHP Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1148 The used command is not allowed with this MySQL version' in /home/ubuntu/mysqltest.php:21 Stack trace: #0 /home/ubuntu/mysqltest.php(21): PDO->exec(

MySQL LOAD DATA LOCAL INFILE example in python?

白昼怎懂夜的黑 提交于 2019-11-29 03:31:20
I am looking for a syntax definition, example, sample code, wiki, etc. for executing a LOAD DATA LOCAL INFILE command from python. I believe I can use mysqlimport as well if that is available, so any feedback (and code snippet) on which is the better route, is welcome. A Google search is not turning up much in the way of current info The goal in either case is the same: Automate loading hundreds of files with a known naming convention & date structure, into a single MySQL table. David Well, using python's MySQLdb, I use this: connection = MySQLdb.Connect(host='**', user='**', passwd='**', db='

What is the fastest way to load an XML file into MySQL using C#?

十年热恋 提交于 2019-11-28 23:37:11
Question What is the fastest way to dump a large (> 1GB) XML file into a MySQL database? Data The data in question is the StackOverflow Creative Commons Data Dump. Purpose This will be used in an offline StackOverflow viewer I am building, since I am looking to do some studying/coding in places where I will not have access to the internet. I would like to release this to the rest of the StackOverflow membership for their own use when the project is finished. Problem Originally, I was reading from XML/writing to DB one record at a time. This took about 10 hours to run on my machine. The

mysqldump table without dumping the primary key

蓝咒 提交于 2019-11-28 19:42:57
问题 I have one table spread across two servers running MySql 4. I need to merge these into one server for our test environment. These tables literally have millions of records each, and the reason they are on two servers is because of how huge they are. Any altering and paging of the tables will give us too huge of a performance hit. Because they are on a production environment, it is impossible for me to alter them in any way on their existing servers. The issue is the primary key is a unique

Parameterizing file name in MYSQL LOAD DATA INFILE

心不动则不痛 提交于 2019-11-28 13:46:24
Is there a way to dynamically specify a file name in the LOAD DATA INFILE? Can it be parameterized like for instance (syntax may be incorrect) LOAD DATA INFILE '$filename'? A citation from MySQL documentation : The LOAD DATA INFILE statement reads rows from a text file into a table at a very high speed. The file name must be given as a literal string. That means that it can not be a parameter of a prepared statement. But no one forbids to make the string interpolation while the statement is just a string in your PHP code. Unfortunately, this feature is not yet supported in MySQL and is