|
|
|
Импорт в БД mysql из CSV
|
|||
|---|---|---|---|
|
#18+
Пытаюсь залить в БД файл csv. LOAD DATA INFILE 'c:\\pasport.csv'] [INTO TABLE `pr_person` character set cp1251 FIELDS TERMINATED BY ';' ENCLOSED BY '"' ESCAPED BY '\\' LINES STARTING BY '' TERMINATED BY '\r\n' ; Программа ругается на дату dtrod. Наверное, потому что в csv формат даты dd.mm.yyyy, в mysql формат yyyy-mm-dd. Как залить файл в связи с этим? ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 10.06.2014, 10:49:58 |
|
||
|
Импорт в БД mysql из CSV
|
|||
|---|---|---|---|
|
#18+
Use the forcegoogleFM, Luke! http://dev.mysql.com/doc/refman/5.1/en/load-data.html первый же коммент: авторConverting strings into dates while loading data using LOAD DATA INFILE: In the following example, we are trying to convert the data in the file for date columns col3, col4 in formats 'mm/dd/yyyy', 'dd/mm/yyyy' into MySQL standard YYYY-mm-dd respectively. load data infile '/tmp/xxx.dat' into table xxx fields terminated by '|' lines terminated by '\n' (col1, col2, @col3, @col4, col5) set col3 = str_to_date(@col3, '%m/%d/%Y'), col4 = str_to_date(@col4, '%d/%m/%Y') ; You could convert into any format you want by using the date_format function around the str_to_date(). Example: ... set col2 = date_format(str_to_date(@col2, 'format'), 'your format') ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 10.06.2014, 11:18:11 |
|
||
|
|

start [/forum/topic.php?fid=47&msg=38666048&tid=1834698]: |
0ms |
get settings: |
8ms |
get forum list: |
22ms |
check forum access: |
2ms |
check topic access: |
2ms |
track hit: |
48ms |
get topic data: |
6ms |
get forum data: |
1ms |
get page messages: |
25ms |
get tp. blocked users: |
1ms |
| others: | 234ms |
| total: | 349ms |

| 0 / 0 |
