mirror of
https://github.com/valitydev/redash.git
synced 2024-11-07 09:28:51 +00:00
Add option to enable Auto Get Schema
This commit is contained in:
parent
f07ed1df31
commit
a98ead9030
@ -48,9 +48,14 @@ class TreasureData(BaseQueryRunner):
|
|||||||
'type': {
|
'type': {
|
||||||
'type': 'string'
|
'type': 'string'
|
||||||
},
|
},
|
||||||
"db": {
|
'db': {
|
||||||
"type": "string",
|
'type': 'string',
|
||||||
"title": "Database Name"
|
'title': 'Database Name'
|
||||||
|
},
|
||||||
|
'getschema': {
|
||||||
|
'type': 'boolean',
|
||||||
|
'title': 'Auto Get Schema',
|
||||||
|
'Default': True
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'required': ['apikey','db']
|
'required': ['apikey','db']
|
||||||
@ -71,16 +76,17 @@ class TreasureData(BaseQueryRunner):
|
|||||||
def __init__(self, configuration):
|
def __init__(self, configuration):
|
||||||
super(TreasureData, self).__init__(configuration)
|
super(TreasureData, self).__init__(configuration)
|
||||||
|
|
||||||
def get_schema(self):
|
def get_schema(self, get_stats=False):
|
||||||
schema = {}
|
schema = {}
|
||||||
try:
|
if self.configuration.get('getschema') == True:
|
||||||
with tdclient.Client(self.configuration.get('apikey')) as client:
|
try:
|
||||||
for table in client.tables(self.configuration.get('db')):
|
with tdclient.Client(self.configuration.get('apikey')) as client:
|
||||||
table_name = '{}.{}'.format(self.configuration.get('db'), table.name)
|
for table in client.tables(self.configuration.get('db')):
|
||||||
for table_schema in table.schema:
|
table_name = '{}.{}'.format(self.configuration.get('db'), table.name)
|
||||||
schema[table_name] = {'name': table_name, 'columns': table.schema}
|
for table_schema in table.schema:
|
||||||
except Exception, ex:
|
schema[table_name] = {'name': table_name, 'columns': table.schema}
|
||||||
raise Exception("Failed getting schema")
|
except Exception, ex:
|
||||||
|
raise Exception("Failed getting schema")
|
||||||
return schema.values()
|
return schema.values()
|
||||||
|
|
||||||
def run_query(self, query):
|
def run_query(self, query):
|
||||||
|
Loading…
Reference in New Issue
Block a user