Skip to content

Commit b0daa21

Browse files
author
Chris Fonnesbeck
committed
Merge pull request #114 from memmett/master
Tweak CREATE TABLE statement and allow SQLITE errors to propagate up.
2 parents c903738 + 756d775 commit b0daa21

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

pymc/database/sqlite.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,10 @@ def _initialize(self, chain, length):
6464

6565
# Create the variable name strings.
6666
vstr = ', '.join(v + ' FLOAT' for v in var_str(self._shape))
67-
68-
try:
69-
query = "create table [%s] (recid INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, trace int(5), %s )" % (self.name, vstr)
70-
71-
self.db.cur.execute(query)
72-
except OperationalError:
73-
"Table already exists"
74-
return
67+
query = """CREATE TABLE IF NOT EXISTS [%s]
68+
(recid INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
69+
trace int(5), %s)""" % (self.name, vstr)
70+
self.db.cur.execute(query)
7571

7672

7773

0 commit comments

Comments
 (0)