# [DuckORM](https://pypi.org/project/duck-orm/)
The `Duck-ORM` package is an asynchronous ORM for Python, with support for **Postgres** and **SQLite**. ORM is built with:
- [databases](https://github.com/encode/databases)
**Requirements**: Python 3.8+
**Duck-ORM is still under development**.
## Installation
```bash
$ pip install duck-orm
```
!!! note
Don't forget to install `databases` before installing `duck-orm`.
## Quickstart
For this example we will create a connection to the SQLite database and create a model.
```bash
$ pip install databases[sqlite]
$ pip install ipython
```
Note that we want to use `ipython` here, because it supports using await expressions directly from the console.
### Creating the connection to the SQLite database:
```Python
from databases import Database
from duck_orm.model import Model
db = Database('sqlite:///example.db')
await db.connect()
```
### Defining a model:
```Python
from duck_orm.sql import fields as Field
class Person(Model):
__tablename__ = 'persons'
__db__ = db
id: int = Field.Integer(primary_key=True, auto_increment=True)
first_name: str = Field.String(unique=True)
last_name: str = Field.String(not_null=True)
age: int = Field.BigInteger(min_value=18)
# Table creation in the database.
await Person.create()
```
- The `__tablename__` attribute is used to define the table's name in the database.
- The `__db__` attribute is the instance of the database connection.
- And then the definition of the fields, their types and restrictions.
- And finally, the table creation in the database.
## Author
- Rich Ramalho - [@richecr](https://github.com/richecr) - [@richzinho_ecr](https://twitter.com/richzinho_ecr)
## License
`DuckORM` is built as an open-source tool and remains completely free(MIT license).
Raw data
{
"_id": null,
"home_page": "",
"name": "duck-orm",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8,<4.0",
"maintainer_email": "",
"keywords": "orm,async,aiohttp,asyncio,databases,database,postgres,sqlite",
"author": "Rich",
"author_email": "richelton14@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/72/6a/d9a7fff184e01270d3120cfab6ccfc68ec134292b286228544b03f3dcf0a/duck_orm-1.0.2.tar.gz",
"platform": null,
"description": "# [DuckORM](https://pypi.org/project/duck-orm/)\n\nThe `Duck-ORM` package is an asynchronous ORM for Python, with support for **Postgres** and **SQLite**. ORM is built with:\n\n- [databases](https://github.com/encode/databases)\n\n**Requirements**: Python 3.8+\n\n**Duck-ORM is still under development**.\n\n## Installation\n\n```bash\n$ pip install duck-orm\n```\n\n!!! note\n Don't forget to install `databases` before installing `duck-orm`. \n\n## Quickstart\n\nFor this example we will create a connection to the SQLite database and create a model.\n\n```bash\n$ pip install databases[sqlite]\n$ pip install ipython\n```\n\nNote that we want to use `ipython` here, because it supports using await expressions directly from the console.\n\n### Creating the connection to the SQLite database:\n\n```Python\nfrom databases import Database\nfrom duck_orm.model import Model\n\ndb = Database('sqlite:///example.db')\nawait db.connect()\n```\n\n### Defining a model:\n\n```Python\nfrom duck_orm.sql import fields as Field\n\nclass Person(Model):\n __tablename__ = 'persons'\n __db__ = db\n\n id: int = Field.Integer(primary_key=True, auto_increment=True)\n first_name: str = Field.String(unique=True)\n last_name: str = Field.String(not_null=True)\n age: int = Field.BigInteger(min_value=18)\n\n# Table creation in the database.\nawait Person.create()\n```\n\n- The `__tablename__` attribute is used to define the table's name in the database.\n- The `__db__` attribute is the instance of the database connection.\n- And then the definition of the fields, their types and restrictions.\n- And finally, the table creation in the database.\n\n## Author\n\n- Rich Ramalho - [@richecr](https://github.com/richecr) - [@richzinho_ecr](https://twitter.com/richzinho_ecr)\n\n## License\n\n`DuckORM` is built as an open-source tool and remains completely free(MIT license).\n",
"bugtrack_url": null,
"license": "LICENSE",
"summary": "ORM Async for Python",
"version": "1.0.2",
"project_urls": null,
"split_keywords": [
"orm",
"async",
"aiohttp",
"asyncio",
"databases",
"database",
"postgres",
"sqlite"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "9904822378f6569ae1475e344cde5ae0d4b6a23fd715f09df41c57c3a8f18823",
"md5": "d941cac94ed67b29e7c8bbefddd177d0",
"sha256": "ffda0625834e7d343c5b12183ae56fdd450f44d91fdd0d06a83dd9e8c4031dc4"
},
"downloads": -1,
"filename": "duck_orm-1.0.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "d941cac94ed67b29e7c8bbefddd177d0",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8,<4.0",
"size": 15139,
"upload_time": "2023-05-13T18:37:50",
"upload_time_iso_8601": "2023-05-13T18:37:50.965727Z",
"url": "https://files.pythonhosted.org/packages/99/04/822378f6569ae1475e344cde5ae0d4b6a23fd715f09df41c57c3a8f18823/duck_orm-1.0.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "726ad9a7fff184e01270d3120cfab6ccfc68ec134292b286228544b03f3dcf0a",
"md5": "cb3175dfcafd84998710c6ca20db14dc",
"sha256": "492b4d1beb0838ca3781b43fbf18d3a6f71f3263b76416cd5fe247500b4cd789"
},
"downloads": -1,
"filename": "duck_orm-1.0.2.tar.gz",
"has_sig": false,
"md5_digest": "cb3175dfcafd84998710c6ca20db14dc",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8,<4.0",
"size": 11753,
"upload_time": "2023-05-13T18:37:52",
"upload_time_iso_8601": "2023-05-13T18:37:52.417859Z",
"url": "https://files.pythonhosted.org/packages/72/6a/d9a7fff184e01270d3120cfab6ccfc68ec134292b286228544b03f3dcf0a/duck_orm-1.0.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-05-13 18:37:52",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "duck-orm"
}