Skip to content

Instantly share code, notes, and snippets.

@iTrauco
Forked from LarsKumbier/export.sql
Created April 16, 2019 03:48
Show Gist options
  • Save iTrauco/517bfc4f7c824df014a90dc286b603a9 to your computer and use it in GitHub Desktop.
Save iTrauco/517bfc4f7c824df014a90dc286b603a9 to your computer and use it in GitHub Desktop.
Export Postgresql for mongoimport
COPY (
SELECT
userid AS "userId.auto()",
'some-static-string' AS "__classname__.auto()",
failed_login_count AS "failedLoginCount.int32()",
CASE WHEN mail_validated=TRUE THEN 'TRUE' ELSE 'FALSE' END AS "mailValidated.boolean()",
-42 AS "answers.toTheQuestion.int32()",
'Slate Star Codex' AS "answers.niceBlog.auto()"
FROM
users.accounts
) TO '/tmp/users-accounts.csv' WITH (FORMAT CSV, HEADER TRUE, DELIMITER E'\t');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment