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, DimensionGroup, Measure from lookmlgen.base_generator import GeneratorFormatOptions view_name = 'my_view' v = View(view_name, sql_table_name='my_table') v.add_field(Dimension('id', type='number', primary_key=True)) v.add_field(DimensionGroup('created')) v.add_field(Dimension('name')) v.add_field(Dimension('quantity', type='number')) v.add_field(Measure('total_quantity', sql='${TABLE}.quantity', type='sum')) with open('%s.view.lkml' % view_name, 'w') as f: v.generate_lookml(f, GeneratorFormatOptions(view_fields_alphabetical=False))
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 { sql_table_name: my_table ;; dimension: id { type: number primary_key: yes sql: ${TABLE}.id ;; } dimension_group: created { type: time timeframes: ["time", "date", "week", "month"] datatype: datetime sql: ${TABLE}.created ;; } dimension: name { sql: ${TABLE}.name ;; } dimension: quantity { type: number sql: ${TABLE}.quantity ;; } measure: total_quantity { type: sum sql: ${TABLE}.quantity ;; } }
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
0.1.4 (2017-04-20)
Support sql_table_name
Add formatting option for alphabetical view fields or not
0.1.5 (2017-04-24)
Rename add_derived_table method to set_derived_table in View
0.1.7 (2017-06-20)
Added formatting option to omit timeframe generating params if they’re not set
Update pytest to 3.1.2, cryptography to 1.9, sphinx to 1.6.2
0.1.8 (2017-06-23)
Add a description parameter to fields
0.1.9 (2017-06-23)
Bug fix for extra newlines between field type sections
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
File details
Details for the file lookml-gen-0.1.9.tar.gz
.
File metadata
- Download URL: lookml-gen-0.1.9.tar.gz
- Upload date:
- Size: 18.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fca13866e434cc3f5a2bf99e975c9d957df9761023e516ffdcf17a5aa9750bfc |
|
MD5 | 0c8c6dabc17aad87c1dc841ca60e71cb |
|
BLAKE2b-256 | ca799f9e225f049de5d77f549acd7d542c5613e26c6dc5e912854f646d6092bf |
File details
Details for the file lookml_gen-0.1.9-py2.py3-none-any.whl
.
File metadata
- Download URL: lookml_gen-0.1.9-py2.py3-none-any.whl
- Upload date:
- Size: 10.9 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f5e276e08bf6b33af64f74fc3fd5f61a6e1fb9f6b8c9151beef92c2779320577 |
|
MD5 | 6b679fd4a83b6eef3893ff69c6442ff6 |
|
BLAKE2b-256 | 47db7a3ca39a9c49f34a1e366c12071cd34d7543409a87fd5deab41fac4cc18b |