Re: Threads, introspection, sharing of :memory: databases
| Newsgroups | gmane.comp.python.db.pysqlite.user |
|---|---|
| Message-ID | <[email protected]> |
Greg> I am sure there are better ways of doing it, but what I do is
Greg> simple:
Greg> def CreateTableFunction()
Greg> try:
Greg> select ID from foo
Greg> except sqlite.DatabaseError:
Greg> cur.execute("""CREATE TABLE foo (ID INTEGER PRIMARY KEY, FIELD1 VARCHAR(50), FIELD2 VARCHAR(30)""")
Greg> Works like a charm...
Yes. Is this any different (logically speaking) than me trying to create
the table and catching the OperationalError though? I'm used to having this
sort of construct available in mysql
CREATE TABLE IF NOT EXISTS `foo` (
...
);
Does sqlite have the ability to detect if a table already exists?
Thx,
Skip