[Tutor] How to test for the existence of a table in a sqlite3 db?

Neil Cerutti neilc at norwich.edu
Thu Oct 19 10:20:43 EDT 2017


On 2017-10-19, Alan Gauld via Tutor <tutor at python.org> wrote:
> On 18/10/17 21:09, Albert-Jan Roskam wrote:
>> 
>> On Oct 16, 2017 15:12, Neil Cerutti <neilc at norwich.edu> 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



More information about the Tutor mailing list