-
-
Save swuecho/fbebd122af13a15505948482768eda56 to your computer and use it in GitHub Desktop.
Postgres: CSV file as a table using FDW
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Installs "file_fdw" extension and creates foreign table to work with data from CSV file. | |
-- See also the comment below which helps to automate the process for Google Spreadsheets | |
-- Another option would be using Multicorn for Google Spreadsheets, but it requires additional steps | |
-- (see https://wiki.postgresql.org/wiki/Foreign_data_wrappers). | |
CREATE EXTENSION file_fdw; | |
CREATE SERVER import FOREIGN DATA WRAPPER file_fdw; | |
CREATE FOREIGN TABLE table1_import ( | |
col1 text, | |
col2 text, | |
... | |
) SERVER import OPTIONS ( filename '/path/to/file.csv', format 'csv' ); | |
-- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
use sqlachemy auto generate schema.