Skip to content

Commit

Permalink
owsql: Try to create missing extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
lanzagar committed Jul 1, 2016
1 parent be46877 commit a92e8d1
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Orange/widgets/data/owsql.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@


MAX_DL_LIMIT = 1000000
EXTENSIONS = ('tsm_system_time', 'quantile')


class OWSql(widget.OWWidget):
Expand Down Expand Up @@ -176,6 +177,7 @@ def connect(self):

def refresh_tables(self):
self.tablecombo.clear()
[self.error(42 + i) for i in range(len(EXTENSIONS))]
if self._connection is None:
self.data_desc_table = None
return
Expand Down Expand Up @@ -215,7 +217,19 @@ def select_table(self):
self.database_desc["Table"] = "(None)"
self.table = None

def create_extensions(self):
for i, ext in enumerate(EXTENSIONS):
try:
cur = self._connection.cursor()
cur.execute("CREATE EXTENSION IF NOT EXISTS " + ext)
self.error(42 + i)
except psycopg2.OperationalError:
self.error(42 + i, 'Database missing extension ' + ext)
finally:
self._connection.commit()

def open_table(self):
self.create_extensions()
table = self.get_table()
self.data_desc_table = table
self.send("Data", table)
Expand Down

0 comments on commit a92e8d1

Please sign in to comment.