Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

import sqls #12985

Closed
wants to merge 1 commit into from
Closed

import sqls #12985

wants to merge 1 commit into from

Conversation

enriquemanuel
Copy link
Contributor

@enriquemanuel enriquemanuel commented Dec 16, 2019

Resolves #12068

Description

Since we are deprecating Looker, I found a way to automate and bring all the "Looks" aka SQL

I have created 2 folders:
dashboards/*
looks_sqls/*

The Dashboards are essentially looks grouped by. if you want to recreate a dashboard, you can just use the sql inside or get the queries accordingly.

Code used

# config.ini
# API version is required
api_version=3.1
# Base URL for API. Do not include /api/* in the url
base_url=http://<looker ip or url for api>:19999
# API 3 client id
client_id=<get yours from the Looker Admin page>
# API 3 client secret
client_secret=<get yours from the Looker Admin page>
# Set to false if testing locally aganst self-signed certs. Otherwise leave True
# creationqueries.py
from looker_sdk import client, models, error
sdk = client.setup('config.ini')
looker_api_user = sdk.me()
looks_ids = list()

for look in sdk.all_looks(fields='id'):
	looks_ids.append(look.id)

for id in looks_ids:
	try:
		sql = sdk.run_look(id, 'sql')
		lookobj = sdk.look(id, fields='title')
		title = lookobj.title
		f = open("sqls/%s.sql"  % (title), "w+")
		f.write(sql)
		
	except:
		continue
	finally:
		f.close()

``

@va-bot
Copy link
Collaborator

va-bot commented Dec 16, 2019

1 Warning
⚠️ This is a Big PR. Try to break this down if possible.

Generated by 🚫 Danger

@codeclimate
Copy link

codeclimate bot commented Dec 16, 2019

Analysis results are not available for those commits

View more on Code Climate.

@pkarman
Copy link
Contributor

pkarman commented Dec 16, 2019

I put these into appeals-team instead, with a README disclaimer that they are not maintained.

@pkarman pkarman closed this Dec 16, 2019
@pkarman pkarman deleted the ev/import_looker_sqls branch December 16, 2019 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migrate Looker reports and alerts
3 participants