Skip to main content

Programmatically generate LookML

Project description

LookML Generator

https://img.shields.io/pypi/v/lookml-gen.svg https://travis-ci.org/symphonyrm/lookml-gen.svg?branch=master Documentation Status Updates

Programmatically generate LookML

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 lookml_gen import view
from lookml_gen import field

v = view.View('my_view')
v.add_field(field.Dimension('id', sql='${TABLE}.c', type='number', primary_key=True))
v.add_field(field.Dimension('c', sql='${TABLE}.c', type='number'))
v.add_field(field.Measure('sum_c', sql='${TABLE}.c', type='sum'))

with open('my_view.lkml', '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}.c ;;
  }

  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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lookml-gen-0.1.0.tar.gz (14.5 kB view hashes)

Uploaded Source

Built Distribution

lookml_gen-0.1.0-py2.py3-none-any.whl (8.6 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page