Binder is a lightweight mapping engine for SQL databases.
Project description
# Binder - A Python SQL Mapper.
Binder is a lightweight SQL mapper for Python.
Install using setup.py:
python setup.py install
## About
Binder lets you define schemas and perform SQL operations using native Python data types and methods. Binder takes care of SQL query generation, parameter passing and data conversion.
Binder is explicitly designed to be a transparent SQL mapping that gives you direct control of what database queries are executed.
To achieve this, Binder is designed as follows:
one SQL row maps to one Python dictionary
one SQL column maps to one key in the Python dictionary
one SQL query maps to one python method in the API
Note that Binder is NOT an ORM and does not provide ORM style features such as parent child containment, lazy loading, etc.
Currently, Binder supports the SQLite (via Python’s built-in sqlite3 module) and MySQL (via the MySQLdb python module)
See manual.txt for full documentation.
## 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}]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file binder-0.5.tar.gz
.
File metadata
- Download URL: binder-0.5.tar.gz
- Upload date:
- Size: 7.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ce96c38748adf5695935069df9fc042b25c8cb72cfc285e8fdec5ca122818014 |
|
MD5 | 8ac1486578454575923eba474b94952b |
|
BLAKE2b-256 | 96b5ff986c4bd358edf7c43af19afa6d9cf7de6d4cd8b5a403e6fdc98d4c84f6 |