{"id":16790423,"url":"https://github.com/sebasg22/supabase_postgres_copy","last_synced_at":"2026-03-18T22:16:19.682Z","repository":{"id":112863697,"uuid":"535328100","full_name":"SebasG22/supabase_postgres_copy","owner":"SebasG22","description":null,"archived":false,"fork":false,"pushed_at":"2022-09-11T14:50:48.000Z","size":3,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-08T04:29:32.288Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SebasG22.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-09-11T14:45:38.000Z","updated_at":"2022-09-11T14:45:38.000Z","dependencies_parsed_at":null,"dependency_job_id":"550efad9-ae1d-4ed4-b7c8-f5c623de6da7","html_url":"https://github.com/SebasG22/supabase_postgres_copy","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SebasG22%2Fsupabase_postgres_copy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SebasG22%2Fsupabase_postgres_copy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SebasG22%2Fsupabase_postgres_copy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SebasG22%2Fsupabase_postgres_copy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SebasG22","download_url":"https://codeload.github.com/SebasG22/supabase_postgres_copy/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243955697,"owners_count":20374373,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-13T08:29:43.808Z","updated_at":"2026-01-03T22:10:34.673Z","avatar_url":"https://github.com/SebasG22.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# How to include new Data\n\nThings to know when we are using CSV files as data into supabase: \n\n1. You can only seed the TABLE if it's a new table\n2. You can have primary keys as AUTOGENERATE Column. Make sure you are not passing into the CSV file.\n\n\n| Name      | Class | Dorm | Room | GPA |\n| ----------| ------|------|------|-----|\n| Sally Whittaker| 2018 | McCarren House | 312 | 3.75 |\n| Belinda Jameson \t|2017 | \tCushing House| 148 | 3.52 |\n| Jeff Smith | 2018 | Prescott House | 17-D | 3.20 |\n| Sandy Allen | 2019 |\tOliver House |\t108 |\t3.48 |\n\nThe above data could be represented in a CSV-formatted file as follows:\n\n**students.csv**\n```csv\nSally Whittaker,2018,McCarren House,312,3.75\nBelinda Jameson,2017,Cushing House,148,3.52\nJeff Smith,2018,Prescott House,17-D,3.20\nSandy Allen,2019,Oliver House,108,3.4\n```\n\nHere, the fields of data in each row are delimited with a comma and individual rows are separated by a newline.\n\nThe SQL schema for this table can look like this: \n\n```SQL\nCREATE TABLE \"students\"(\n    \"name\" VARCHAR(255) NOT NULL,\n    \"class\" VARCHAR(255) NOT NULL,\n    \"dorm\" VARCHAR(255) NOT NULL,\n    \"room\" VARCHAR(255) NOT NULL,\n    \"gpa\" DOUBLE PRECISION NOT NULL\n);\n```\n\nPlease check that we are not defining the primary key, this process will be done after the seed. \n\nNow we can use the direct connection to import the CSV file. We will use docker to install Postgres locally and have access to the PSQL CLI:\n\n``` bash\n# Pull the image\ndocker pull postgres:alpine\n\n# Create the container\n# We are define a POSTGRES_PASSWORD just because is a requirement for docker image but we will not use it\ndocker run --name demo-postgres -e POSTGRES_PASSWORD=password -d postgres:alpine \n\n# Copy the file into the container\ndocker cp students.csv demo-postgres:students.csv\n\n# Access the container\ndocker exec -it demo-postgres bash\n```\n\nNow you can use the direct connection from Supabase:\n\n1. _Go to settings -\u003e Database -\u003e Connection String_\n\n2. _Choose PSQL, copy and paste the command_\n\nNow you will be prompted for the password of the Supabase project.\n\nYou can validate that you are using the remote connection, by checking the tables information:\n\n```\n# list all the tables\n\\d\n\n# seed database with CSV File\n\\copy students from '/students.csv' DELIMITER ',' CSV;\n```\n\nNow you can see the data in Supabase. At this moment we do not have any primary key, we can add a new column through the UI or SQL CLI and specify that is autogenerate it. \n\n\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsebasg22%2Fsupabase_postgres_copy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsebasg22%2Fsupabase_postgres_copy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsebasg22%2Fsupabase_postgres_copy/lists"}