Best way to get LOAD DATA LOCAL INFILE error?

I am new to MySQL, completing the piece of code inherent in my webapp. The code imports the CSV file (locally), which is created and cleared by FileMaker and leaves it.

With this in mind, it will be launched soon (and perhaps there will be a database under 500 MB), I would really like to know if there is any better check / catch of errors that I could make to prevent problems in the future or to be warned about setting up my server. I read information about temp logs, etc., And my MySQL administration is not yet able to sniff.

The simplest code:

$m = mysql_connect('localhost', 'mytable', 'mypassword'); $db = 'mydb'; mysql_select_db($db) or die("Import Error - Couldn't select database: " . mysql_error()); $sql = 'load data local infile "inventory.csv" into table ibl_account_details_temp fields terminated by "," optionally enclosed by "\"" lines terminated by "\r" (store_id, SKU, account, item_number, brand, description, size, category, price, qty, fees) '; echo mysql_query($sql) or die(myqsl_error()); 

PS EDIT: I would also be interested to know if this import method is open for SQL injection?

+6
source share
1 answer

Unfortunately, error handling with infile download data is very bad. I use it almost every day, and it becomes a simple routine to import into a temporary table, and uses a combination of PHP and MySQL to check what has been imported. It can be argued that this is an additional work, but it has the advantage that I can completely control what a "mistake" is. Simply put, I use it to get the source data in place as efficiently as possible, and then create your error checking and error checking rules in a php script.

+4
source

Source: https://habr.com/ru/post/916057/


All Articles