Skip to content

Instantly share code, notes, and snippets.

@rahulinux
Created November 24, 2021 19:21
Show Gist options
  • Select an option

  • Save rahulinux/3d40e89473e46fd8bfc9330f169d8cbe to your computer and use it in GitHub Desktop.

Select an option

Save rahulinux/3d40e89473e46fd8bfc9330f169d8cbe to your computer and use it in GitHub Desktop.

Revisions

  1. Rahul Patil created this gist Nov 24, 2021.
    23 changes: 23 additions & 0 deletions pg.sql
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    -- Create database assignment
    SELECT 'CREATE DATABASE assignment'
    WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = 'assignment')\gexec

    -- Switch DATABASE

    \c assignment

    --
    -- Name: categories; Type: TABLE; Owner: -; Tablespace:
    --
    CREATE TABLE rides (
    ride_id character varying(32) not null,
    driver_id integer not null,
    passenger_id integer not null,
    started_at timestamp not null,
    PRIMARY KEY (ride_id)
    );

    COPY rides(ride_id, driver_id, passenger_id, started_at)
    FROM '/tmp/corrected_data.csv'
    DELIMITER ','
    CSV HEADER;