<commit_before>=======
SQLpy
=======
|pypi| |build-status| |coverage|

TODO
=======

- clean up exception handling/raise
- Ensure Python 2/3 interop
- Add CI and test process with test queires
- Add support for other database drivers/types

Quickstart
==========

Getting started is simple! All you need is a PostgreSQL database running and accessible to you.

First install sqlpy and psycopg2
::
    $ pip install sqlpy psycopg2

Create a `queries.sql` file in your project directory, containing the following
::
    -- name: test_select
    -- test selection from database
    SELECT * FROM test

Set up the application and run
::
    from sqlpy.sqlpy import Queries, load_queires
    import psycopg2
    import psycopg2.extras

    sql = Queries()

    queries = load_queires('queries.sql')
    for name, fn in queries:
        sql.add_query(name, fn)


    def connect_db():
        db_host = <host>
        db_port = <port>
        db_user = <user>
        db_pass = <password>
        return psycopg2.connect(dbname='postgres',
                                user=db_user,
                                password=<PASSWORD>,
                                host=db_host,
                                port=db_port,
                                cursor_factory=psycopg2.extras.RealDictCursor)


    db = connect_db()

    with db:
        with db.cursor() as cur:
            output = sql.TEST_SELECT(cur, 0)

    print output

    db.close()


.. |build-status| image:: https://travis-ci.org/9fin/sqlpy.svg?branch=master
    :alt: build status
    :scale: 100%
    :target: https://travis-ci.org/9fin/sqlpy

.. |pypi| image:: https://img.shields.io/pypi/v/sqlpy.svg
    :alt: Pypi Version
    :scale: 100%
    :target: https://pypi.python.org/pypi/sqlpy

.. |coverage| image:: https://coveralls.io/repos/github/9fin/sqlpy/badge.svg?branch=master
    :alt: Pypi Version
    :scale: 100%
    :target: https://coveralls.io/github/9fin/sqlpy?branch=master<commit_msg>update readme with versions badge<commit_after>=======
SQLpy
=======
|pypi| |build-status| |coverage| |versions|

TODO
=======

- clean up exception handling/raise
- Ensure Python 2/3 interop
- Add CI and test process with test queires
- Add support for other database drivers/types

Quickstart
==========

Getting started is simple! All you need is a PostgreSQL database running and accessible to you.

First install sqlpy and psycopg2
::
    $ pip install sqlpy psycopg2

Create a `queries.sql` file in your project directory, containing the following
::
    -- name: test_select
    -- test selection from database
    SELECT * FROM test

Set up the application and run
::
    from sqlpy.sqlpy import Queries, load_queires
    import psycopg2
    import psycopg2.extras

    sql = Queries()

    queries = load_queires('queries.sql')
    for name, fn in queries:
        sql.add_query(name, fn)


    def connect_db():
        db_host = <host>
        db_port = <port>
        db_user = <user>
        db_pass = <password>
        return psycopg2.connect(dbname='postgres',
                                user=db_user,
                                password=<PASSWORD>,
                                host=db_host,
                                port=db_port,
                                cursor_factory=psycopg2.extras.RealDictCursor)


    db = connect_db()

    with db:
        with db.cursor() as cur:
            output = sql.TEST_SELECT(cur, 0)

    print output

    db.close()


.. |build-status| image:: https://travis-ci.org/9fin/sqlpy.svg?branch=master
    :alt: build status
    :scale: 100%
    :target: https://travis-ci.org/9fin/sqlpy

.. |pypi| image:: https://img.shields.io/pypi/v/sqlpy.svg
    :alt: Pypi Version
    :scale: 100%
    :target: https://pypi.python.org/pypi/sqlpy

.. |coverage| image:: https://coveralls.io/repos/github/9fin/sqlpy/badge.svg?branch=master
    :alt: Pypi Version
    :scale: 100%
    :target: https://coveralls.io/github/9fin/sqlpy?branch=master

.. |versions| image:: https://img.shields.io/pypi/pyversions/sqlpy.svg
    :alt: Python Versions
    :scale: 100%
    :target: https://pypi.python.org/pypi/sqlpy
{'fraction_non_alphanumeric': 0.11848455598455598, 'fraction_numerical': 0.011341698841698842, 'mean_word_length': 2.316, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 14, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1583685', 'n_tokens_mistral': 1380, 'n_tokens_neox': 1295, 'n_words': 336}