Name | pythrel JSON |
Version |
0.1.1
JSON |
| download |
home_page | https://github.com/iTecAI/pythrel |
Summary | Simple SQL ORM with support for several DB providers |
upload_time | 2023-09-17 01:16:33 |
maintainer | |
docs_url | None |
author | Dax Harris |
requires_python | >=3.10,<4.0 |
license | MIT |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# pythrel
Abstract relational ORM system
**WARNING:** This is a small project I built mainly to learn how to interface with a few different kinds of SQL database. If you would like to use this in production, no you don't!
## Documentation:
**Installation:**
> `python3 -m pip install pythrel`
**Basic Usage:**
```python
from pythrel import SqliteDatabase, Pythrel, Record
import secrets
import random
# Create database adapter
db = SqliteDatabase(path="test.db")
db.create_table("customers", {"id": "INTEGER", "customerName": "TEXT", "favorite_number": "REAL"})
db.commit()
# Generate some data
CUSTOMERS = {}
for c in range(500):
CUSTOMERS[c] = {
"id": c,
"customerName": secrets.token_urlsafe(8),
"favorite_number": random.randint(0, 10000)
}
# Insert data
db.query().insert("customers", list(CUSTOMERS.values())).execute()
db.commit()
# Connect DB instance to ORM
orm = Pythrel(db)
# Use database table rows as objects
print(orm.load_columns(Customer, "customers", "*")[0].dict())
orm.create(Customer, "customers", id=-10, customerName="John", favorite_number=-69)
john = orm.load_columns(Customer, "customers", "*", where="id < 0")[0]
print(john)
john.favorite_number = 1000
orm.save(john, key="id")
print(orm.load_query(Customer, orm.query().select("customers", "*").where("id < 0"))[0])
```
Raw data
{
"_id": null,
"home_page": "https://github.com/iTecAI/pythrel",
"name": "pythrel",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.10,<4.0",
"maintainer_email": "",
"keywords": "",
"author": "Dax Harris",
"author_email": "matteovh@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/95/3d/b399296be55c0f59da1b0423130ed7aae61622e68d6937a6f167a9571bef/pythrel-0.1.1.tar.gz",
"platform": null,
"description": "# pythrel\nAbstract relational ORM system\n\n**WARNING:** This is a small project I built mainly to learn how to interface with a few different kinds of SQL database. If you would like to use this in production, no you don't!\n\n## Documentation:\n\n**Installation:**\n> `python3 -m pip install pythrel`\n\n**Basic Usage:**\n```python\nfrom pythrel import SqliteDatabase, Pythrel, Record\nimport secrets\nimport random\n\n# Create database adapter\ndb = SqliteDatabase(path=\"test.db\")\ndb.create_table(\"customers\", {\"id\": \"INTEGER\", \"customerName\": \"TEXT\", \"favorite_number\": \"REAL\"})\ndb.commit()\n\n# Generate some data\nCUSTOMERS = {}\nfor c in range(500):\n CUSTOMERS[c] = {\n \"id\": c,\n \"customerName\": secrets.token_urlsafe(8),\n \"favorite_number\": random.randint(0, 10000)\n }\n\n# Insert data\ndb.query().insert(\"customers\", list(CUSTOMERS.values())).execute()\ndb.commit()\n\n# Connect DB instance to ORM\norm = Pythrel(db)\n\n# Use database table rows as objects\nprint(orm.load_columns(Customer, \"customers\", \"*\")[0].dict())\norm.create(Customer, \"customers\", id=-10, customerName=\"John\", favorite_number=-69)\njohn = orm.load_columns(Customer, \"customers\", \"*\", where=\"id < 0\")[0]\nprint(john)\njohn.favorite_number = 1000\norm.save(john, key=\"id\")\nprint(orm.load_query(Customer, orm.query().select(\"customers\", \"*\").where(\"id < 0\"))[0])\n```",
"bugtrack_url": null,
"license": "MIT",
"summary": "Simple SQL ORM with support for several DB providers",
"version": "0.1.1",
"project_urls": {
"Homepage": "https://github.com/iTecAI/pythrel",
"Repository": "https://github.com/iTecAI/pythrel"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "23a1ccd68126892d5df8b9ef98a9d3ee04ac6fb9ee0bfd416b9df6cfeb52cde0",
"md5": "94dc4023dd32cf5f4441672710951b47",
"sha256": "7ee08990ee3a6dfa812412f31d65ec3e27c21175b79a6839b358ead3185a7982"
},
"downloads": -1,
"filename": "pythrel-0.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "94dc4023dd32cf5f4441672710951b47",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10,<4.0",
"size": 8287,
"upload_time": "2023-09-17T01:16:31",
"upload_time_iso_8601": "2023-09-17T01:16:31.966434Z",
"url": "https://files.pythonhosted.org/packages/23/a1/ccd68126892d5df8b9ef98a9d3ee04ac6fb9ee0bfd416b9df6cfeb52cde0/pythrel-0.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "953db399296be55c0f59da1b0423130ed7aae61622e68d6937a6f167a9571bef",
"md5": "c1fef49b188d884addeca94ad90c06c9",
"sha256": "d8d9ed3d0ad62815564c18c1f318ce7d4be358a9b79ea1c37c256299f4dae81f"
},
"downloads": -1,
"filename": "pythrel-0.1.1.tar.gz",
"has_sig": false,
"md5_digest": "c1fef49b188d884addeca94ad90c06c9",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10,<4.0",
"size": 5284,
"upload_time": "2023-09-17T01:16:33",
"upload_time_iso_8601": "2023-09-17T01:16:33.794713Z",
"url": "https://files.pythonhosted.org/packages/95/3d/b399296be55c0f59da1b0423130ed7aae61622e68d6937a6f167a9571bef/pythrel-0.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-09-17 01:16:33",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "iTecAI",
"github_project": "pythrel",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "pythrel"
}