JohnnieRunner
JohnnieRunner is SQLAlchemy Wrapper for Active Record pattern O/R Mapper
Dependencies
Python2.7 or Later
SQLAlchemy >= 1.0.8
MySQL-Python >= 1.2.5
Support RDBMS
MySQL
Goal
Add Rails like ActiveRecord Api
Database Migration
All Supports of SQLAlchemy RDBMS
Usage
Prepare
generate testing database
$ mysql -u root -p mysql> create database johnnie; Query OK, 1 row affected (0.01 sec) mysql> exit; Byedefine O/R Mapper structure
from johnnie import AbstractModel, create_session from johnnie.types import Column, String, Integer session = create_session('localhost', 'root', 'root user password', 'johnnie') class Repositories(AbstractModel): class Meta: session = session id = Column('id', Integer(unsigned=True), primary_key=True) name = Column('name', String(255), nullable=False) author = Column('author', String(255), nullable=False) url = Column('url', String(255), nullable=False)create model table
$ python >>> from hoge import Repositories >>> Repositories.metadata.create_all(Repositories.get_session_engine()) >>> exit()
Example
create entity
>>> from hoge import Repositories >>> entity = Repositories(name="JohnnieRunner", author="teitei-tk", url="https://github.com/teitei-tk/JohnnieRunner") or >>> entity_data = {"name": "JohnnieRunner", "author": "teitei-tk", "url": "https://github.com/teitei-tk/JohnnieRunner"} >>> entity = Repositories.new(entity_data)create record
>>> entity.save() Truemysql> select * from repositories; +----+---------------+-----------+--------------------------------------------+ | id | name | author | url | +----+---------------+-----------+--------------------------------------------+ | 1 | JohnnieRunner | teitei-tk | https://github.com/teitei-tk/JohnnieRunner | +----+---------------+-----------+--------------------------------------------+ 1 row in set (0.00 sec) mysql>read record
>>> entity = Repositories.get(1) or >>> entity = Repositories.find(1) >>> entity.name u"JohnnieRunner" >>> entity.author u"teitei-tk" >>> entity.url u"https://github.com/teitei-tk/JohnnieRunner"update record
>>> entity.name = u"update_test" >>> entity.save() Truemysql> select * from repositories; +----+-------------+-----------+--------------------------------------------+ | id | name | author | url | +----+-------------+-----------+--------------------------------------------+ | 1 | update_test | teitei-tk | https://github.com/teitei-tk/JohnnieRunner | +----+-------------+-----------+--------------------------------------------+ mysql>delete record
>>> entity.delete() Truemysql> select * from repositories; Empty set (0.00 sec)
TODO
[ ] Add DB Data Types
[ ] Easy generate table index
[ ] Easy Table RelationShips
[ ] Database Migration
[ ] RDBMS Support other than MySQL
License
MIT
Metadata
Release files for JohnnieRunner 0.0.1
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 |
|---|---|---|---|---|
| JohnnieRunner-0.0.1.tar.gz | 4.5 kB | Without provenance | Details for JohnnieRunner-0.0.1.tar.gz |
Release files / JohnnieRunner-0.0.1.tar.gz
| Download URL | JohnnieRunner-0.0.1.tar.gz |
|---|---|
| Size | 4.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
25372a69d656d4f76b1a25c04f624b86783123b800aad3a953302d498e466092
|
|
BLAKE2b-256 checksum How to use checksums |
12b2f6d9b60613095ab2bf1534a91c5962f08da1094171b86d6f39d335d28a8d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for JohnnieRunner 0.0.1
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.