Skip to main content

Easy SQL in Python

Project description

anosql
======

A Python library for using SQL

*Warning: very alpha*

Inspired by the excellent [Yesql][1] library by Kris Jenkins. In my mother
tongue, *ano* means *yes*.

Installation
------------

```
$ pip install anosql
```

Usage
-----

Given a `queries.sql` file:

```sql
-- name: get-all-greetings
-- Get all the greetings in the database
SELECT * FROM greetings;
```

We can issue SQL queries, like so:

```python
import anosql
import psycopg2
import sqlite3

# PostgreSQL
conn = psycopg2.connect('...')
queries = anosql.load_queries('postgres', 'queries.sql')

# Or, Sqlite3...
conn = sqlite3.connect('cool.db')
queries = anosql.load_queries('sqlite', 'queries.sql')

queries = queries.get_all_greetings(conn)
# => [(1, 'Hi')]

queries.get_all_greetings.__doc__
# => Get all the greetings in the database

queries.available_queries
# => ['get_all_greetings']
```

Caveats
-------

Postgresql and sqlite only at the moment

License
-------

BSD, short and sweet

[1]: https://github.com/krisajenkins/yesql/

Project details


Release history Release notifications

History Node

0.2.0

History Node

0.1.2

History Node

0.1.1

This version
History Node

0.1.0

History Node

0.0.2

History Node

0.0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
anosql-0.1.0.tar.gz (2.2 kB) Copy SHA256 hash SHA256 Source None Aug 31, 2014

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page