-
Notifications
You must be signed in to change notification settings - Fork 0
/
sql_queries.py
29 lines (23 loc) · 1.42 KB
/
sql_queries.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# USERS
drop_users = "DROP TABLE IF EXISTS USERS"
create_users = "CREATE TABLE IF NOT EXISTS USERS(USER_ID INT, FIRST_NAME VARCHAR, LAST_NAME VARCHAR, GENDER VARCHAR, \
LEVEL VARCHAR, PRIMARY KEY(USER_ID, LEVEL))"
# ARTISTS
drop_artists = "DROP TABLE IF EXISTS ARTISTS"
create_artists = "CREATE TABLE IF NOT EXISTS ARTISTS(idArtist BIGSERIAL PRIMARY KEY, ARTIST_ID VARCHAR \
NOT NULL UNIQUE, NAME TEXT, LOCATION TEXT, LATITUDE TEXT, LONGITUDE TEXT)"
# SONGS
drop_songs = "DROP TABLE IF EXISTS SONGS"
create_songs = "CREATE TABLE IF NOT EXISTS SONGS(idSong BIGSERIAL PRIMARY KEY, SONG_ID VARCHAR NOT NULL UNIQUE, \
TITLE VARCHAR, ARTIST_ID VARCHAR, YEAR INT, DURATION FLOAT)"
# TIME
drop_time = "DROP TABLE IF EXISTS TIME"
create_time = "CREATE TABLE IF NOT EXISTS TIME(START_TIME TIMESTAMP PRIMARY KEY, HOUR INT, DAY INT, WEEK INT, \
MONTH INT, YEAR INT, WEEKDAY VARCHAR)"
# SONGPLAYS
drop_songplays = "DROP TABLE IF EXISTS SONGPLAYS"
create_songplays = "CREATE TABLE IF NOT EXISTS SONGPLAYS(SONGPLAY_ID BIGSERIAL PRIMARY KEY, START_TIME TIMESTAMP, \
USER_ID INT, LEVEL VARCHAR, idSong INT, idArtist INT, SESSION_ID INT, \
LOCATION VARCHAR, USER_AGENT TEXT)"
list_drop_tables = [drop_users, drop_artists, drop_songs, drop_time, drop_songplays]
list_create_tables = [create_users, create_artists, create_songs, create_time, create_songplays]