Skip to content

Commit e44a750

Browse files
committed
added if not exist in table creation in database
1 parent 0032b51 commit e44a750

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

scripts/database.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def get_universe_data(start_date: Optional[str] = None,
143143

144144
def create_universe_table():
145145
universe_query = """
146-
CREATE TABLE universe (
146+
CREATE TABLE IF NOT EXISTS universe (
147147
date DATE NOT NULL,
148148
ticker VARCHAR(50) NOT NULL,
149149
open NUMERIC(18,6),
@@ -168,7 +168,7 @@ def create_portfolio_tables():
168168
# ===============================
169169

170170
snapshots_query = """
171-
CREATE TABLE portfolio_snapshots (
171+
CREATE TABLE IF NOT EXISTS portfolio_snapshots (
172172
date DATE NOT NULL,
173173
portfolio_name VARCHAR(50) NOT NULL,
174174
@@ -194,7 +194,7 @@ def create_portfolio_tables():
194194
"""
195195

196196
positions_query = """
197-
CREATE TABLE portfolio_positions (
197+
CREATE TABLE IF NOT EXISTS portfolio_positions (
198198
date DATE NOT NULL,
199199
portfolio_name VARCHAR(50) NOT NULL,
200200
ticker VARCHAR(10) NOT NULL,
@@ -219,7 +219,7 @@ def create_portfolio_tables():
219219
"""
220220

221221
trades_query = """
222-
CREATE TABLE portfolio_trades (
222+
CREATE TABLE IF NOT EXISTS portfolio_trades (
223223
id SERIAL PRIMARY KEY,
224224
date DATE NOT NULL,
225225
portfolio_name VARCHAR(50) NOT NULL,

0 commit comments

Comments
 (0)