This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sqlalchemy import create_engine, MetaData, Table | |
import json | |
OS_DATASET = "de-bund" | |
def get_os_metadata(dataset_name): | |
engine = create_engine("postgres://postgres@localhost/openspending") | |
md = MetaData(bind=engine) | |
table = Table("dataset", md, autoload=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[server] | |
debug=yes | |
log_level=debug | |
reload=yes | |
backend = sql.star | |
prettyprint = true | |
[workspace] | |
url = postgres://postgres@localhost/openspending |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sqlalchemy | |
import cubes | |
import cubes.tutorial.sql as tutorial | |
DATA = "../examples/hello_world/data.csv" | |
MODEL = "../examples/hello_world/model.json" | |
engine = sqlalchemy.create_engine('sqlite:///:memory:') | |
tutorial.create_table_from_csv(engine, | |
DATA, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cubes": [ | |
{ | |
"name": "example", | |
"measures": ["amount"], | |
"dimensions": ["date"], | |
"mappings": { | |
"date.year": {"column":"date", "extract":"year"}, | |
"date.month": {"column":"date", "extract":"month"}, | |
"date.day": {"column":"date", "extract":"day"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ "keys": ["ctrl+q"], "command": "wrap_lines" }, | |
{ "keys": ["super+shift+v"], "command": "paste" }, | |
{ "keys": ["super+v"], "command": "paste_and_indent" } | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sqlalchemy | |
import carray | |
from sqlalchemy.types import * | |
BUFFER_SIZE = 100 | |
dtype_map = [ | |
(BigInteger, "i"), | |
(SmallInteger, "i"), | |
(Boolean, "i"), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import brewery | |
stream = brewery.Stream() | |
main = stream.fork() | |
main.csv_source("examples/data2.csv") | |
main.field_filter(drop=["category_code", "subcategory_code", "line_item"]) | |
main.pretty_printer() | |
stream.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Run this script in cubes/examples/hello_world | |
import cubes | |
model = cubes.load_model("model.json") | |
workspace = cubes.create_workspace("sql", model, | |
url='sqlite:///data.sqlite') | |
cube = model.cube("irbd_balance") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask, render_template, request | |
import cubes | |
app = Flask(__name__) | |
# | |
# Data we aregoing to browse and logical model of the data | |
# | |
MODEL_PATH = "model.json" | |
DB_URL = "sqlite:///data.sqlite" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask, render_template, request | |
import cubes | |
import json | |
app = Flask(__name__) | |
# | |
# Data we aregoing to browse and logical model of the data | |
# | |
MODEL_PATH = "model.json" |