Here is the code
import os
import psycopg2
conn = psycopg2.connect(
host="localhost",
database="postgres",
user=os.environ['DB_USERNAME'],
password=os.environ['DB_PASSWORD'])
cur = conn.cursor()
cur.execute('DROP TABLE IF EXISTS user;')
cur.execute('CREATE TABLE user (id serial PRIMARY KEY,'
'email varchar (100) UNIQUE,'
'password varchar (100) NOT NULL,'
'name varchar (1000) NOT NULL);'
)
conn.commit()
cur.close()
conn.close()
and here is the error i'm getting
Traceback (most recent call last):
File "/testApp/app/init_db.py", line 14, in <module>
cur.execute('DROP TABLE IF EXISTS user;')
psycopg2.errors.SyntaxError: syntax error at or near "user"
LINE 1: DROP TABLE IF EXISTS user;
Do you have any ideas on why am i getting this error? I really can't see where is the syntax error. Thanks