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
# -*- coding: utf8 -*- | |
from bubbles import Pipeline | |
stores = { | |
"package": {"type": "datapackages", "url": "data" } | |
} | |
p = Pipeline(stores=stores) |
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
Total | |
---------------------- | |
Record count: 62 | |
Total amount: 1116860 | |
Drill Down by Category (top-level Item hierarchy) | |
================================================= | |
Category Count Total | |
---------------------------------------- | |
Assets 32 558430 |
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
class CreateTableAsSelect(Executable, ClauseElement): | |
def __init__(self, table, select): | |
self.table = table | |
self.select = select | |
@compiles(CreateTableAsSelect) | |
def visit_create_table_as_select(element, compiler, **kw): | |
preparer = compiler.dialect.preparer(compiler.dialect) | |
full_name = preparer.format_table(element.table) |
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, Integer, Date, Column | |
import sqlalchemy.sql as sql | |
engine = create_engine("sqlite://") | |
md = MetaData(bind=engine) | |
table = Table("data", md) | |
table.append_column(Column("id", Integer)) | |
table.append_column(Column("adate", Date)) | |
table.append_column(Column("value", Integer)) |
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 bubbles import Pipeline, ExecutionEngine | |
from bubbles import operation, datasource | |
# New implicit iterator operations | |
@datasource(fields=["i"]) | |
def generator(context, count=10): | |
for i in range(count): | |
yield [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
from sqlalchemy import sql | |
from collections import OrderedDict | |
def simple_upsert(source, target, source_key, target_key, mapping): | |
"""Simple transformative upsert from `source` table into `target` table | |
where `source_key` is unique key in the `source` table amd `target_key` | |
is its equivalend in the `target` table. `mapping` is a dictionary that | |
maps between target's column names and source column names. | |
Returns a tuple of two statements (`update`, `insert`). |
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
{-# LANGUAGE MultiParamTypeClasses #-} | |
import Text.Printf | |
data SQLLiteral | |
= SQLFloatLiteral Float | |
| SQLIntLiteral Integer | |
| SQLStringLiteral String | |
deriving (Show, Eq) |
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
//: Playground - noun: a place where people can play | |
// Note: we are using underscode instead of camelCase for gramar rules | |
// to maintain consistency with common practice in BNF | |
import ParserCombinator | |
extension Token: EmptyCheckable { | |
public static let EmptyValue = Token(.Empty, "") | |
public var isEmpty: Bool { return self.kind == TokenKind.Empty } |
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
# Concepts | |
# -------- | |
CONCEPT linker | |
TAG ready | |
SLOT left, right | |
CONCEPT link | |
TAG free | |
SLOT next |
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
# Self-organizing trees | |
# | |
CONCEPT node | |
TAG free | |
SLOT left, right | |
CONCEPT head | |
TAG open, node | |
SLOT left, right |