https://github.com/pythonicninja/pydrill_dsl
PyDrill DSL
https://github.com/pythonicninja/pydrill_dsl
Last synced: 8 months ago
JSON representation
PyDrill DSL
- Host: GitHub
- URL: https://github.com/pythonicninja/pydrill_dsl
- Owner: PythonicNinja
- License: isc
- Created: 2016-05-01T14:41:33.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2022-12-26T19:44:56.000Z (over 3 years ago)
- Last Synced: 2025-02-05T04:46:14.274Z (over 1 year ago)
- Language: Python
- Homepage: https://pydrill_dsl.readthedocs.org
- Size: 51.8 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.rst
- Changelog: HISTORY.rst
- Contributing: CONTRIBUTING.rst
- License: LICENSE
Awesome Lists containing this project
README
===============================
pyDrill-dsl
===============================
.. image:: https://img.shields.io/travis/PythonicNinja/pydrill_dsl.svg
:target: https://travis-ci.org/PythonicNinja/pydrill_dsl
.. image:: https://img.shields.io/pypi/v/pydrill_dsl.svg
:target: https://pypi.python.org/pypi/pydrill_dsl
.. image:: https://readthedocs.org/projects/pydrill_dsl/badge/?version=latest
:target: https://readthedocs.org/projects/pydrill_dsl/?badge=latest
:alt: Documentation Status
.. image:: https://coveralls.io/repos/github/PythonicNinja/pydrill_dsl/badge.svg
:target: https://coveralls.io/github/PythonicNinja/pydrill_dsl
Pythonic DSL for `Apache Drill `_.
*Schema-free SQL Query Engine for Hadoop, NoSQL and Cloud Storage*
* Free software: MIT license
* Documentation: https://pydrill_dsl.readthedocs.org.
Features
--------
* Uses Peewee syntax. `examples for selecting data are in peewee docs `_.
* Support for all storage plugins
* Support for drivers PyODBC and pyDrill
Installation
------------
::
Version from https://pypi.python.org/pypi/pydrill_dsl::
$ pip install pydrill_dsl
Latest version from git::
$ pip install git+git://github.com/PythonicNinja/pydrill_dsl.git
Sample usage
------------
::
from pydrill_dsl.resource import Resource
class Employee(Resource):
first_name = Field()
salary = Field()
position_id = Field()
department_id = Field()
class Meta:
storage_plugin = 'cp'
path = 'employee.json'
# by default it uses pydrill
# example of using pydobc
# database = Drill({'dsn': 'Driver=/opt/mapr/drillodbc/lib/universal/libmaprdrillodbc.dylib;ConnectionType=Direct;Host=127.0.0.1;Port=31010;Catalog=DRILL;AuthenticationType=Basic Authentication;AdvancedProperties=CastAnyToVarchar=true;HandshakeTimeout=5;QueryTimeout=180;TimestampTZDisplayTimezone=utc;ExcludedSchemas=sys,INFORMATION_SCHEMA;NumberOfPrefetchBuffers=5;UID=[USERNAME];PWD=[PASSWORD]'})
Employee.select().filter(salary__gte=17000)
Employee.select().paginate(page=1, paginate_by=5)
salary_gte_17K = (Employee.salary >= 17000)
salary_lte_25K = (Employee.salary <= 25000)
Employee.select().where(salary_gte_17K & salary_lte_25K)
Employee.select(
fn.Min(Employee.salary).alias('salary_min'),
fn.Max(Employee.salary).alias('salary_max')
).scalar(as_tuple=True)
# creation of resource can be done without creation of class:
employee = Resource(storage_plugin='cp', path='employee.json',
fields=('first_name', 'salary', 'position_id', 'department_id'))