# Binder - A Python SQL Mapper.
Binder is a lightweight SQL mapper for Python that lets you perform SQL operations using native Python data types and methods:
>>> conn.select(Trades, AND(Trades.q.symbol=='RHAT', Trades.q.trans=='BUY'))
[{'date': datetime.date(2006, 1, 5), 'symbol': u'RHAT', 'trans': u'BUY', 'price'
: 35.0, 'qty': 100}]
A database row is mapped to a Python dictionary containing native Python data types. Binder gives you control of what SQL query is executed, while taking care of query generation, parameter passing and data conversion.
Currently, Binder supports the SQLite (via Python’s built-in sqlite3 module), PostgreSQL (via psycopg2) and MySQL (via the MySQLdb python module).
See manual.txt for full documentation.
## Installing
Install using pip:
pip install binder
Install from source:
python setup.py install
## Quick Tour
Define the schema for a table:
>>> from binder import *
>>> Trades = Table("trades",
... DateCol("date"), UnicodeCol("trans", 4), UnicodeCol("symbol", 4),
... IntCol("qty"), FloatCol("price")
... )
Creating a new database using SQLite and create the table we defined above:
>>> conn = SqliteConnection("readme.db3")
>>> conn.create_table(Trades)
Insert a row using a regular Python dictionary:
>>> from datetime import date
>>> row = {
... "date":date(2006, 1, 5), "trans":"BUY", "symbol":"RHAT",
... "qty":100, "price":35
... }
>>> conn.insert(Trades, row)
>>> conn.commit()
Finally, retrieve the data:
>>> conn.select(Trades)
[{'date': datetime.date(2006, 1, 5), 'symbol': u'RHAT', 'trans': u'BUY', 'price'
: 35.0, 'qty': 100}]
Metadata
Release files for binder 0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| binder-0.6.tar.gz | 8.3 kB | Without provenance | Details for binder-0.6.tar.gz |
Release files / binder-0.6.tar.gz
| Download URL | binder-0.6.tar.gz |
|---|---|
| Size | 8.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8548986d61dd4ad59d447eb22dcafe48af9c06d6e2adcd67f12098e806806623
|
|
BLAKE2b-256 checksum How to use checksums |
03e23606600b8b67b0f9ca52c3aada5222cf9d5a90b91b86e0fb2a343743af63
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for binder 0.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.