0

How would I implement the following command in python:

ALTER TABLE {tableName} ADD COLUMN COLNew {type};

Taken from this post

I assume it would look something like the following:

cursor.execute('ALTER TABLE my_table ADD COLUMN COLNEW ... ???

The problem is there are lots of sqlite tutorials for python and lots of sqlite examples. How does one convert a sqlite command to python?

Colonel
  • 19
  • 4
  • 2
    Why is having a lot of available tutorials a problem? Did you work through any of them before asking? – Bryan Oakley Jul 09 '18 at 17:42
  • What exactly are you having difficulty with? If you have a SQL query that works, then it should also work as `cursor.execute()`. There's some stuff to learn about parameter substitution, but unless you describe exactly what you don't understand, we can't really help you any more than the [documentation](https://docs.python.org/3/library/sqlite3.html) or any tutorial could. – glibdud Jul 09 '18 at 17:43
  • +1 Bryan, plus you don't give what kind of values you want to put in that column, which would help to choose the type for the column. – Baptiste Mille-Mathias Jul 09 '18 at 17:44

0 Answers0