impyla


Nameimpyla JSON
Version 0.19.0 PyPI version JSON
download
home_pagehttps://github.com/cloudera/impyla
SummaryPython client for the Impala distributed query engine
upload_time2023-11-22 04:08:46
maintainerWes McKinney
docs_urlNone
authorUri Laserson
requires_python
licenseApache License, Version 2.0
keywords cloudera impala python hadoop sql hdfs mpp spark pydata pandas distributed db api pep 249 hive hiveserver2 hs2
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            # impyla

Python client for HiveServer2 implementations (e.g., Impala, Hive) for
distributed query engines.

For higher-level Impala functionality, including a Pandas-like interface over
distributed data sets, see the [Ibis project][ibis].

### Features

* HiveServer2 compliant; works with Impala and Hive, including nested data

* Fully [DB API 2.0 (PEP 249)][pep249]-compliant Python client (similar to
sqlite or MySQL clients) supporting Python 2.6+ and Python 3.3+.

* Works with Kerberos, LDAP, SSL

* [SQLAlchemy][sqlalchemy] connector

* Converter to [pandas][pandas] `DataFrame`, allowing easy integration into the
Python data stack (including [scikit-learn][sklearn] and
[matplotlib][matplotlib]); but see the [Ibis project][ibis] for a richer
experience

### Dependencies

Required:

* Python 2.7+ or 3.5+

* `six`, `bitarray`

* `thrift==0.16.0`

* `thrift_sasl==0.4.3`

Optional:

* `kerberos>=1.3.0` for Kerberos over HTTP support. This also requires Kerberos libraries
   to be installed on your system - see [System Kerberos](#system-kerberos)

* `pandas` for conversion to `DataFrame` objects; but see the [Ibis project][ibis] instead

* `sqlalchemy` for the SQLAlchemy engine

* `pytest` for running tests; `unittest2` for testing on Python 2.6


#### System Kerberos

Different systems require different packages to be installed to enable Kerberos support in
Impyla. Some examples of how to install the packages on different distributions follow.

Ubuntu:
```bash
apt-get install libkrb5-dev krb5-user
```

RHEL/CentOS:
```bash
yum install krb5-libs krb5-devel krb5-server krb5-workstation
```

### Installation

Install the latest release with `pip`:

```bash
pip install impyla
```

For the latest (dev) version, install directly from the repo:

```bash
pip install git+https://github.com/cloudera/impyla.git
```

or clone the repo:

```bash
git clone https://github.com/cloudera/impyla.git
cd impyla
python setup.py install
```

#### Running the tests

impyla uses the [pytest][pytest] toolchain, and depends on the following
environment variables:

```bash
export IMPYLA_TEST_HOST=your.impalad.com
export IMPYLA_TEST_PORT=21050
export IMPYLA_TEST_AUTH_MECH=NOSASL
```

To run the maximal set of tests, run

```bash
cd path/to/impyla
py.test --connect impala
```

Leave out the `--connect` option to skip tests for DB API compliance.


### Usage

Impyla implements the [Python DB API v2.0 (PEP 249)][pep249] database interface
(refer to it for API details):

```python
from impala.dbapi import connect
conn = connect(host='my.host.com', port=21050)
cursor = conn.cursor()
cursor.execute('SELECT * FROM mytable LIMIT 100')
print cursor.description  # prints the result set's schema
results = cursor.fetchall()
```

The `Cursor` object also exposes the iterator interface, which is buffered
(controlled by `cursor.arraysize`):

```python
cursor.execute('SELECT * FROM mytable LIMIT 100')
for row in cursor:
    print(row)
```

Furthermore the `Cursor` object returns you information about the columns
returned in the query. This is useful to export your data as a csv file.

```python
import csv

cursor.execute('SELECT * FROM mytable LIMIT 100')
columns = [datum[0] for datum in cursor.description]
targetfile = '/tmp/foo.csv'

with open(targetfile, 'w', newline='') as outcsv:
    writer = csv.writer(outcsv, delimiter=',', quotechar='"', quoting=csv.QUOTE_ALL, lineterminator='\n')
    writer.writerow(columns)
    for row in cursor:
        writer.writerow(row)
```

You can also get back a pandas DataFrame object

```python
from impala.util import as_pandas
df = as_pandas(cur)
# carry df through scikit-learn, for example
```


[pep249]: http://legacy.python.org/dev/peps/pep-0249/
[pandas]: http://pandas.pydata.org/
[sklearn]: http://scikit-learn.org/
[matplotlib]: http://matplotlib.org/
[pytest]: http://pytest.org/latest/
[sqlalchemy]: http://www.sqlalchemy.org/
[ibis]: http://www.ibis-project.org/

# How do I contribute code?
You need to first sign and return an
[ICLA](https://github.com/cloudera/native-toolchain/blob/icla/Cloudera%20ICLA_25APR2018.pdf)
and
[CCLA](https://github.com/cloudera/native-toolchain/blob/icla/Cloudera%20CCLA_25APR2018.pdf)
before we can accept and redistribute your contribution. Once these are submitted you are
free to start contributing to impyla. Submit these to CLA@cloudera.com.

## Find
We use Github issues to track bugs for this project. Find an issue that you would like to
work on (or file one if you have discovered a new issue!). If no-one is working on it,
assign it to yourself only if you intend to work on it shortly.

It's a good idea to discuss your intended approach on the issue. You are much more
likely to have your patch reviewed and committed if you've already got buy-in from the
impyla community before you start.

## Fix
Now start coding! As you are writing your patch, please keep the following things in mind:

First, please include tests with your patch. If your patch adds a feature or fixes a bug
and does not include tests, it will generally not be accepted. If you are unsure how to
write tests for a particular component, please ask on the issue for guidance.

Second, please keep your patch narrowly targeted to the problem described by the issue.
It's better for everyone if we maintain discipline about the scope of each patch. In
general, if you find a bug while working on a specific feature, file a issue for the bug,
check if you can assign it to yourself and fix it independently of the feature. This helps
us to differentiate between bug fixes and features and allows us to build stable
maintenance releases.

Finally, please write a good, clear commit message, with a short, descriptive title and
a message that is exactly long enough to explain what the problem was, and how it was
fixed.

Please create a pull request on github with your patch.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/cloudera/impyla",
    "name": "impyla",
    "maintainer": "Wes McKinney",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "wes.mckinney@twosigma.com",
    "keywords": "cloudera impala python hadoop sql hdfs mpp spark pydata pandas distributed db api pep 249 hive hiveserver2 hs2",
    "author": "Uri Laserson",
    "author_email": "laserson@cloudera.com",
    "download_url": "https://files.pythonhosted.org/packages/d0/08/42b154578aec1497d5c5462cbc1a840ea56c9626af9daa8c06ddf3246707/impyla-0.19.0.tar.gz",
    "platform": null,
    "description": "# impyla\n\nPython client for HiveServer2 implementations (e.g., Impala, Hive) for\ndistributed query engines.\n\nFor higher-level Impala functionality, including a Pandas-like interface over\ndistributed data sets, see the [Ibis project][ibis].\n\n### Features\n\n* HiveServer2 compliant; works with Impala and Hive, including nested data\n\n* Fully [DB API 2.0 (PEP 249)][pep249]-compliant Python client (similar to\nsqlite or MySQL clients) supporting Python 2.6+ and Python 3.3+.\n\n* Works with Kerberos, LDAP, SSL\n\n* [SQLAlchemy][sqlalchemy] connector\n\n* Converter to [pandas][pandas] `DataFrame`, allowing easy integration into the\nPython data stack (including [scikit-learn][sklearn] and\n[matplotlib][matplotlib]); but see the [Ibis project][ibis] for a richer\nexperience\n\n### Dependencies\n\nRequired:\n\n* Python 2.7+ or 3.5+\n\n* `six`, `bitarray`\n\n* `thrift==0.16.0`\n\n* `thrift_sasl==0.4.3`\n\nOptional:\n\n* `kerberos>=1.3.0` for Kerberos over HTTP support. This also requires Kerberos libraries\n   to be installed on your system - see [System Kerberos](#system-kerberos)\n\n* `pandas` for conversion to `DataFrame` objects; but see the [Ibis project][ibis] instead\n\n* `sqlalchemy` for the SQLAlchemy engine\n\n* `pytest` for running tests; `unittest2` for testing on Python 2.6\n\n\n#### System Kerberos\n\nDifferent systems require different packages to be installed to enable Kerberos support in\nImpyla. Some examples of how to install the packages on different distributions follow.\n\nUbuntu:\n```bash\napt-get install libkrb5-dev krb5-user\n```\n\nRHEL/CentOS:\n```bash\nyum install krb5-libs krb5-devel krb5-server krb5-workstation\n```\n\n### Installation\n\nInstall the latest release with `pip`:\n\n```bash\npip install impyla\n```\n\nFor the latest (dev) version, install directly from the repo:\n\n```bash\npip install git+https://github.com/cloudera/impyla.git\n```\n\nor clone the repo:\n\n```bash\ngit clone https://github.com/cloudera/impyla.git\ncd impyla\npython setup.py install\n```\n\n#### Running the tests\n\nimpyla uses the [pytest][pytest] toolchain, and depends on the following\nenvironment variables:\n\n```bash\nexport IMPYLA_TEST_HOST=your.impalad.com\nexport IMPYLA_TEST_PORT=21050\nexport IMPYLA_TEST_AUTH_MECH=NOSASL\n```\n\nTo run the maximal set of tests, run\n\n```bash\ncd path/to/impyla\npy.test --connect impala\n```\n\nLeave out the `--connect` option to skip tests for DB API compliance.\n\n\n### Usage\n\nImpyla implements the [Python DB API v2.0 (PEP 249)][pep249] database interface\n(refer to it for API details):\n\n```python\nfrom impala.dbapi import connect\nconn = connect(host='my.host.com', port=21050)\ncursor = conn.cursor()\ncursor.execute('SELECT * FROM mytable LIMIT 100')\nprint cursor.description  # prints the result set's schema\nresults = cursor.fetchall()\n```\n\nThe `Cursor` object also exposes the iterator interface, which is buffered\n(controlled by `cursor.arraysize`):\n\n```python\ncursor.execute('SELECT * FROM mytable LIMIT 100')\nfor row in cursor:\n    print(row)\n```\n\nFurthermore the `Cursor` object returns you information about the columns\nreturned in the query. This is useful to export your data as a csv file.\n\n```python\nimport csv\n\ncursor.execute('SELECT * FROM mytable LIMIT 100')\ncolumns = [datum[0] for datum in cursor.description]\ntargetfile = '/tmp/foo.csv'\n\nwith open(targetfile, 'w', newline='') as outcsv:\n    writer = csv.writer(outcsv, delimiter=',', quotechar='\"', quoting=csv.QUOTE_ALL, lineterminator='\\n')\n    writer.writerow(columns)\n    for row in cursor:\n        writer.writerow(row)\n```\n\nYou can also get back a pandas DataFrame object\n\n```python\nfrom impala.util import as_pandas\ndf = as_pandas(cur)\n# carry df through scikit-learn, for example\n```\n\n\n[pep249]: http://legacy.python.org/dev/peps/pep-0249/\n[pandas]: http://pandas.pydata.org/\n[sklearn]: http://scikit-learn.org/\n[matplotlib]: http://matplotlib.org/\n[pytest]: http://pytest.org/latest/\n[sqlalchemy]: http://www.sqlalchemy.org/\n[ibis]: http://www.ibis-project.org/\n\n# How do I contribute code?\nYou need to first sign and return an\n[ICLA](https://github.com/cloudera/native-toolchain/blob/icla/Cloudera%20ICLA_25APR2018.pdf)\nand\n[CCLA](https://github.com/cloudera/native-toolchain/blob/icla/Cloudera%20CCLA_25APR2018.pdf)\nbefore we can accept and redistribute your contribution. Once these are submitted you are\nfree to start contributing to impyla. Submit these to CLA@cloudera.com.\n\n## Find\nWe use Github issues to track bugs for this project. Find an issue that you would like to\nwork on (or file one if you have discovered a new issue!). If no-one is working on it,\nassign it to yourself only if you intend to work on it shortly.\n\nIt's a good idea to discuss your intended approach on the issue. You are much more\nlikely to have your patch reviewed and committed if you've already got buy-in from the\nimpyla community before you start.\n\n## Fix\nNow start coding! As you are writing your patch, please keep the following things in mind:\n\nFirst, please include tests with your patch. If your patch adds a feature or fixes a bug\nand does not include tests, it will generally not be accepted. If you are unsure how to\nwrite tests for a particular component, please ask on the issue for guidance.\n\nSecond, please keep your patch narrowly targeted to the problem described by the issue.\nIt's better for everyone if we maintain discipline about the scope of each patch. In\ngeneral, if you find a bug while working on a specific feature, file a issue for the bug,\ncheck if you can assign it to yourself and fix it independently of the feature. This helps\nus to differentiate between bug fixes and features and allows us to build stable\nmaintenance releases.\n\nFinally, please write a good, clear commit message, with a short, descriptive title and\na message that is exactly long enough to explain what the problem was, and how it was\nfixed.\n\nPlease create a pull request on github with your patch.\n",
    "bugtrack_url": null,
    "license": "Apache License, Version 2.0",
    "summary": "Python client for the Impala distributed query engine",
    "version": "0.19.0",
    "project_urls": {
        "Homepage": "https://github.com/cloudera/impyla"
    },
    "split_keywords": [
        "cloudera",
        "impala",
        "python",
        "hadoop",
        "sql",
        "hdfs",
        "mpp",
        "spark",
        "pydata",
        "pandas",
        "distributed",
        "db",
        "api",
        "pep",
        "249",
        "hive",
        "hiveserver2",
        "hs2"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "80e7243a9f336cce1120c629f4cde4fb60688be00f14774ad034fe2f10ca6f0d",
                "md5": "84bafcbff445b9141b07194f004a558a",
                "sha256": "99ebfea347850072464568099ca3e481dd4dacaaca8a725bd64a288fc7e991d7"
            },
            "downloads": -1,
            "filename": "impyla-0.19.0-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "84bafcbff445b9141b07194f004a558a",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 277986,
            "upload_time": "2023-11-22T04:08:43",
            "upload_time_iso_8601": "2023-11-22T04:08:43.271518Z",
            "url": "https://files.pythonhosted.org/packages/80/e7/243a9f336cce1120c629f4cde4fb60688be00f14774ad034fe2f10ca6f0d/impyla-0.19.0-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d00842b154578aec1497d5c5462cbc1a840ea56c9626af9daa8c06ddf3246707",
                "md5": "ca11e11cf8902d0e218ddeb0a24ded9d",
                "sha256": "729b0067e90a20204d5fb9d11822214964e298dc8c11e4d142c11a367720ea4f"
            },
            "downloads": -1,
            "filename": "impyla-0.19.0.tar.gz",
            "has_sig": false,
            "md5_digest": "ca11e11cf8902d0e218ddeb0a24ded9d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 258942,
            "upload_time": "2023-11-22T04:08:46",
            "upload_time_iso_8601": "2023-11-22T04:08:46.593282Z",
            "url": "https://files.pythonhosted.org/packages/d0/08/42b154578aec1497d5c5462cbc1a840ea56c9626af9daa8c06ddf3246707/impyla-0.19.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-22 04:08:46",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "cloudera",
    "github_project": "impyla",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": false,
    "lcname": "impyla"
}
        
Elapsed time: 0.20518s