Skip to content

KrammyGod/hoops

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

99 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Production Site:

The production deployment of this application is available at https://hoops-tan.vercel.app/

Required:

Download Postgres V14+ (V15 preferred) at https://www.postgresql.org/download/

Setting up Environment:

First, you can login with:

psql -h db.qqbfgpnkateniubtbotc.supabase.co -p 5432 -d test_db -U user_name, replacing user_name with the one you were provided. You will be prompted to enter your password, you can change your password once you logged in, by typing \password

Basically, the database host is db.qqbfgpnkateniubtbotc.supabase.co, the port # is 5432, the database name is test_db and the user you are logging into is user_name

Finally, if you are tired of typing your password all the time, you can do psql postgres://user_name:password@db.qqbfgpnkateniubtbotc.supabase.co/test_db to auto login, changing password to whatever your password is

You can simply replace test_db with whatever the database name is, once we confirm a name.

To login locally in the repo, you must put the following in app/.env file (you have to create one, a sample has been provided)

PGHOST=db.qqbfgpnkateniubtbotc.supabase.co
PGDATABASE=test_db
PGUSER=user_name
PGPASSWORD=password
NEXTAUTH_SECRET=secret

Replacing user_name with your username, password with your password, and test_db with whatever database you wish to use. REMEMBER TO NOT COMMIT THIS FILE!!!! (should be already included in .gitignore)

The secret can be generated by running openssl rand -base64 32. This MUST be done for site to be functional.

Directories

~/sql <- folder containing all .sql files (schema/queries)

~/samples <- folder containing test input/output for features

Importing CSV Datasets

Create a temporary table with ALL the columns in the CSV, so that we can use the \copy command:

CREATE TEMPORARY TABLE tmp (column_names data_type);

Remember that you can also modify this table for values that should be NULL, but aren't:

UPDATE tmp SET column = NULL WHERE column = 'NA'

Then, create the actual table with the dataset we want:

CREATE TABLE table_name (column_names data_type);

Copy all values from CSV to temporary table:

\copy tmp FROM '/path/to/file' WITH (HEADER MATCH, FORMAT csv);

Copy all required columns from tmp to actual table:

INSERT INTO table_name SELECT column_names FROM tmp;

Delete tmp to reuse:

DROP TABLE tmp;

How to save .out from .sql

You have two options:

Option 1

In your .sql file, include this line at the top of the file:

\o sample.out

and run it with

cat sample.sql | psql -h db.qqbfgpnkateniubtbotc.supabase.co -p 5432 -d test_db -U user_name

or on Windows:

type sample.sql | psql -h db.qqbfgpnkateniubtbotc.supabase.co -p 5432 -d test_db -U user_name

Option 2

Simply use output redirection:

cat sample.sql | psql -h db.qqbfgpnkateniubtbotc.supabase.co -p 5432 -d test_db -U user_name > sample.out

or on Windows:

type sample.sql | psql -h db.qqbfgpnkateniubtbotc.supabase.co -p 5432 -d test_db -U user_name > sample.out

An example of option 1 is included in ~/examples/sample.sql

Using Next.js

First, run the development server:

npm run dev
# or
yarn dev
# or
pnpm dev

Open http://localhost:3000 with your browser to see the result.

About

Website of NBA stats w/ Next.JS & PostgreSQL

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 5