Help solve the problem associated with checking sqlite3 for the presence of a table. Suppose I need that if a table is already created, then a similar error was not output table b already exists I certainly tried to search the forums for a workaround for such an error was a similar variant OperationalError, but it does not fit

conn = sqlite3.connect('bd/to.db') c = conn.cursor() c.execute('CREATE TABLE kon'+o+' (id int auto_increment primary key,vopros char(150),otv1 varchar(50),otv2 varchar(50),otv3 varchar(50),pravotv varchar(50))') try: print('ok') except OperationalError: print('есть') 

    1 answer 1

    You can check in the following way:

    SELECT name FROM sqlite_master WHERE type='table' AND name='название_таблицы';

    or so:

    create table if not exists название_таблицы;