Dharmendra Yadav
Dharmendra Yadav

Reputation: 59

Getting error like "syntax error at or near "TEXT"

Getting below error:

I am adding new column to postgresql

newColquery ='ALTER TABLE dwb_weekly_snapshot ADD COLUMN CT_ID data_type TEXT' 


  File "C:/Users/bz_dyadav/PycharmProjects/pythonProject/venv/Scripts/dwb_update.py", line 24, in <module>
    result_dwb_snapshot = cursor.execute(newColquery)
  File "D:\python\Python37\lib\site-packages\pg8000\legacy.py", line 205, in execute
    raise cls(msg)
pg8000.dbapi.ProgrammingError: {'S': 'ERROR', 'V': 'ERROR', 'C': '42601', 'M': 'syntax error at or near "TEXT"', 'P': '60', 'F': 'scan.l', 'L': '1134', 'R': 'scanner_yyerror'}

Upvotes: 0

Views: 649

Answers (1)

tadman
tadman

Reputation: 211560

In the documentation on ALTER TABLE the text data_type refers to your data type, not the literal word. It's in bold-italic meaning "placeholder name".

Easy fix:

newColquery ='ALTER TABLE dwb_weekly_snapshot ADD COLUMN CT_ID TEXT' 

Upvotes: 1

Related Questions