This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
notes:postgres [2015/08/11 14:18] jiggak |
notes:postgres [2015/08/17 14:05] jiggak |
||
---|---|---|---|
Line 6: | Line 6: | ||
< | < | ||
- | -- run bcp in windows cmd to dump table | + | bcp " |
- | bcp Campaign | + | </ |
- | -- convert line endings to unix | + | |
- | dos2unix campaign.data | + | <code bash> |
- | -- import data with psql | + | # |
- | copy campaign from '/media/sf_D_DRIVE/pg_migrate/campaign.data' | + | |
- | </code? | + | for f in *.data; do |
+ | echo $f | ||
+ | cat $f | \ | ||
+ | sed 's/\xf7/|\n|/g' | \ | ||
+ | # remove extra at end of file | ||
+ | sed '$ s/.$//' | \ | ||
+ | # add missing at start of file | ||
+ | sed '1 s/ | ||
+ | sed ' | ||
+ | sed ' | ||
+ | sed ' | ||
+ | sed ' | ||
+ | sed ' | ||
+ | sed ' | ||
+ | sed ' | ||
+ | # dos2unix identified these non-char bytes | ||
+ | tr -d ' | ||
+ | # dos2unix | \ | ||
+ | iconv -f WINDOWS-1252 -t UTF8 > $f.csv | ||
+ | done | ||
+ | </ | ||
+ | |||
+ | <code sql> | ||
+ | \copy event (id, | ||
+ | select setval('event_id_seq', (select max(id) from event)); | ||
+ | </code> |