Re: [Tutor] How to test for the existence of a table in a sqlite3 db?
On 18/10/17 21:09, Albert-Jan Roskam wrote: > > On Oct 16, 2017 15:12, Neil Cerutti wrote: >> sqlite3 module. In sqlite modifying table definitions is limited >> to the simple addition of a new row of data. > > Really? How so? I used ALTER TABLE ADD COLUMN the other day, I think Neil meant that Sqlite ALTER is limited to adding *columns*. Adding rows would be an INSERT not an ALTER. The only other thing SQLite ALTER can do is change the table name. But most SQLs allow you to modify existing column definitions too, such as add defaults or conditions. You can't do that in SQLite, you need to create a new table (TEMP)and copy the data across then drop the old table and rename the new one to the old. All a bit tedious. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] How to test for the existence of a table in a sqlite3 db?
On 2017-10-19, Alan Gauld via Tutor wrote: > On 18/10/17 21:09, Albert-Jan Roskam wrote: >> >> On Oct 16, 2017 15:12, Neil Cerutti wrote: > >>> sqlite3 module. In sqlite modifying table definitions is limited >>> to the simple addition of a new row of data. > >> >> Really? How so? I used ALTER TABLE ADD COLUMN the other day, > > I think Neil meant that Sqlite ALTER is limited to adding > *columns*. Adding rows would be an INSERT not an ALTER. > > The only other thing SQLite ALTER can do is change the table name. > > But most SQLs allow you to modify existing column definitions > too, such as add defaults or conditions. You can't do that in > SQLite, you need to create a new table (TEMP)and copy the data > across then drop the old table and rename the new one to the > old. All a bit tedious. Yes, I meant sqlite can only add columns. Thanks for the corrections. -- Neil Cerutti ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor