Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how to check if a column exists before alter the table

conn = sqlite3.connect(':memory:')
c = conn.cursor()
try:
    c.execute('ALTER TABLE mytable ADD COLUMN newcolumn;')
except:
    pass # handle the error
c.close()
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #check #column #exists #alter #table
ADD COMMENT
Topic
Name
1+1 =