Programmatically generate LookML
Project description
LookML Generator
Programmatically generate LookML
Free software: Apache Software License 2.0
Documentation: https://lookml-gen.readthedocs.io.
Features
Generate LookML views programmatically
Include dimensions, dimension groups, filters, and measures in your views
Support Persistent Derived Tables (PDTs)
Write output to files or StringIO buffers
Quick Start
Install it:
pip install lookml-gen
Use it:
from lookmlgen.view import View from lookmlgen.field import Dimension, Measure view_name = 'my_view' v = View(view_name) v.add_field(Dimension('id', type='number', primary_key=True)) v.add_field(Dimension('c', type='number')) v.add_field(Measure('sum_c', sql='${TABLE}.c', type='sum')) with open('%s.view.lkml' % view_name, 'w') as f: v.generate_lookml(f)
See it:
# STOP! This file was generated by an automated process. # Any edits you make will be lost the next time it is # re-generated. view: my_view { dimension: c { type: number sql: ${TABLE}.c ;; } dimension: id { primary_key: yes type: number sql: ${TABLE}.id ;; } measure: sum_c { type: sum sql: ${TABLE}.c ;; } }
TODOs
Full LookML support is far from complete right now. At the moment only very basic aspects of Views and Fields are supported and there is no support for Explores yet. However, it does cover the most common functionality, including Persistent Derived Tables. The code can easily be extended and we’d love to get pull requests to fill out additional functionality.
Credits
This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.
History
0.1.0 (2017-04-17)
First release on PyPI.
0.1.1 (2017-04-17)
Switch to lookmlgen for module name
0.1.2 (2017-04-18)
Move primary_key from Field to Dimension
Remove stub for command line use
Add docstrings
0.1.3 (2017-04-20)
Default sql parameter of fields to ${TABLE}.field_name
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for lookml_gen-0.1.3-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8a463b418f53f90535f450348c83f5a4df72cf115aca63212d6a968c658c4227 |
|
MD5 | 825cd5d14d9aee9e7b748ddda772b0dd |
|
BLAKE2b-256 | 24622c23892204b0e4de684a597389d224c8ae9a0772b6fbecf3856715d72a77 |