On Tue, Apr 5, 2011 at 6:59 PM, michael scott <jigenbak...@yahoo.com> wrote: > Hello guys, > > Since sqlite gives an error if you try to create a table that's already > there, how do I test if a table is already present? > > > for example in > > def database(info): > import sqlite3 > > connection = sqlite3.connect("test.db") > cursor = connection.cursor() > if table not in test.db: #with this being my test that I'm not sure how > to implement
See http://www.sqlite.org/faq.html#q7 For example: select * from sqlite_master where name='test'; Alternatively, if the only purpose in checking to see if the table exists is so that it can be created, you can simple do: create table if not exists test (...); _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor