# FastSQLModel
<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->
## Overview
FastSQLModel is a utility for simplifying the process of using
SQLModel/SQLAlchemy and Alembic. It provides a CLI for initializing and
managing Alembic migrations, and a set of tools for working with
SQLModel and SQLAlchemy models.
## Features
- **CLI for Alembic**: FastSQLModel provides a CLI for initializing and
managing Alembic migrations.
- **SQLModel and SQLAlchemy Models**: FastSQLModel provides a set of
tools for working with SQLModel and SQLAlchemy models.
- **Database Management**: FastSQLModel provides a set of tools for
managing the database, including creating, dropping, and querying the
database.
## Developer Guide
### Install FastSQLModel in Development
If you want to make changes to the package, you can install it in
development mode. This project uses nbdev for development, so you can
make changes to the code and documentation in the notebooks under the
nbs/ directory. To find out more about amazing nbdev, visit the [nbdev
documentation](https://nbdev.fast.ai/index.html).
To make changes to the package, you can install it in development mode.
``` sh
# make sure FastSQLModel package is installed in development mode
$ pip install -e .
# make changes under nbs/ directory
# ...
# compile to have changes apply to FastSQLModel
$ nbdev_prepare
```
## Usage
### Installation
Install latest from the GitHub
[repository](https://github.com/ndendic/FastSQLModel):
``` sh
$ pip install git+https://github.com/ndendic/FastSQLModel.git
```
or from [conda](https://anaconda.org/ndendic/FastSQLModel)
``` sh
$ conda install -c ndendic FastSQLModel
```
or from [pypi](https://pypi.org/project/FastSQLModel/)
``` sh
$ pip install FastSQLModel
```
To establish a connection to the database, please specify the
`DATABASE_URL` in the `.env` file.
### Documentation
Documentation can be found hosted on this GitHub
[repository](https://github.com/ndendic/FastSQLModel)’s
[pages](https://ndendic.github.io/FastSQLModel/). Additionally you can
find package manager specific guidelines on
[conda](https://anaconda.org/ndendic/FastSQLModel) and
[pypi](https://pypi.org/project/FastSQLModel/) respectively.
## How to use
### Create your first model
To create your first model, you can can import the BaseTable class from
the FastSQLModel.db module and create a new model by subclassing it.
BaseTable is a subclass of SQLModel, so it has all the same features,
but it also has a few extra features to help with some standard db
operations and 3 extra fields: - id: primary key, default to a uuid4 -
created_at: datetime, default to now - updated_at: datetime, default to
now, and updated on every save
``` python
class BaseTable(SQLModel):
model_config = ConfigDict(json_encoders={datetime: lambda dt: dt.isoformat()})
id: UUID = Field(default_factory=uuid4, primary_key=True)
created_at: datetime = Field(
default_factory=utc_now,
sa_type= sa.DateTime(timezone=True),
sa_column_kwargs={"server_default": sa.func.now()},
nullable=False,
title="Created At",
schema_extra={"icon": "clock", "input_type": "datetime"},
)
updated_at: datetime = Field(
default_factory=utc_now,
sa_type=sa.DateTime(timezone=True),
sa_column_kwargs={
"server_default": sa.func.now(),
"server_onupdate": sa.func.now(),
},
# onupdate=utc_now,
nullable=False,
title="Updated At",
schema_extra={"icon": "clock", "input_type": "datetime"},
)
```
Here is an example of how to create a new model using BaseTable
``` python
# users.py
from typing import Optional
from sqlmodel import Field
from datetime import datetime
from FastSQLModel.db import BaseTable
class User(BaseTable, table=True):
name: Optional[str] = Field(nullable=True)
email: str = Field(nullable=False)
password: str = Field(nullable=False)
joined_at: datetime = Field(nullable=False)
```
Now that you have created your first model, you can use the CLI to
initialize and manage Alembic project.
``` sh
$ fastmodel init
```
This will create a new Alembic project in the current directory, and
create a new .alembic.ini file.
2. Then make sure to add your models to the migrations/env.py file
before running migrations.
``` python
# migrations/env.py
from users import User
# ...
```
3. Now you can run migrations to prepare the database for your models.
``` sh
$ fastmodel migrations
```
4. And now you can migrate your models to the database.
``` sh
$ fastmodel migrate
```
Let’s see how this works
Initialization:
``` python
# !fastmodel init
```
Successfully initialized Alembic in migrations directory!
Please make sure to add your models to migrations/env.py file before running
migrations!
Making migrations
``` python
!fastmodel migrations
```
Generating Alembic migration with message: Pushing changes
DATABASE_URL sqlite:///test.db
INFO [alembic.runtime.migration] Context impl SQLiteImpl.
INFO [alembic.runtime.migration] Will assume non-transactional DDL.
INFO [alembic.autogenerate.compare] Detected added table 'user'
Generating /home/ndendic/WebDev/FastSQLModel/nbs/migrations/versions/4d9613e97
da3_pushing_changes.py ... done
Migration created successfully!
Migrating changes
``` python
!fastmodel migrate
```
Applying database migrations...
DATABASE_URL sqlite:///test.db
INFO [alembic.runtime.migration] Context impl SQLiteImpl.
INFO [alembic.runtime.migration] Will assume non-transactional DDL.
INFO [alembic.runtime.migration] Running upgrade -> 4d9613e97da3, Pushing changes
Migrations applied successfully!
Once our table is migrated, we can start adding some data like this.
``` python
user = User(name="Homer Simpson", email="homer@simpson.com", password="password", joined_at=datetime.now())
user.save()
user.model_dump()
```
{'name': 'Homer Simpson',
'email': 'homer@simpson.com',
'password': 'password',
'joined_at': datetime.datetime(2024, 12, 19, 16, 41, 37, 575422),
'id': UUID('4b3a4311-6103-4694-8954-d6771233bc97'),
'created_at': datetime.datetime(2024, 12, 19, 15, 41, 37, 576371, tzinfo=datetime.timezone.utc),
'updated_at': datetime.datetime(2024, 12, 19, 15, 41, 37, 576413, tzinfo=datetime.timezone.utc)}
Let’s get our user by id
``` python
homer = User.get(user.id)
if homer:
print(f"Name: {homer.name}, Email: {homer.email}")
else:
print("User not found")
```
Name: Homer Simpson, Email: homer@simpson.com
Or by alternative key value
``` python
homer = User.get("homer@simpson.com",alt_key="email")
if homer:
print(f"Name: {homer.name}, Email: {homer.email}")
else:
print("User not found")
```
Name: Homer Simpson, Email: homer@simpson.com
Now let’s modify our record and save it back to our database and
retreive back
``` python
homer.email = "homer.simpson@simpson.com"
homer.save()
homer = User.get("homer.simpson@simpson.com",alt_key="email")
homer.email
```
'homer.simpson@simpson.com'
Let’s define a bit more Simprons, this time like this
``` python
bart = User()
bart.name = "Bart Simpson"
bart.email = "bart@simpson.com"
bart.password = "password"
bart.joined_at = datetime.now()
bart.save()
bart.name, bart.email
```
('Bart Simpson', 'bart@simpson.com')
Let’s retrive records in our table. We can simply do that by calling
`all` function
``` python
User.all()
```
[User(name='Homer Simpson', email='homer.simpson@simpson.com', joined_at=datetime.datetime(2024, 12, 19, 16, 41, 32, 766940), id=UUID('fc724993-651f-47ea-a332-e2318e9c09a2'), created_at=datetime.datetime(2024, 12, 19, 15, 41, 32, 784370), updated_at=datetime.datetime(2024, 12, 19, 15, 41, 37, 952971), password='password'),
User(name='Homer Simpson', email='homer@simpson.com', joined_at=datetime.datetime(2024, 12, 19, 16, 41, 37, 575422), id=UUID('4b3a4311-6103-4694-8954-d6771233bc97'), created_at=datetime.datetime(2024, 12, 19, 15, 41, 37, 589591), updated_at=datetime.datetime(2024, 12, 19, 15, 41, 37, 589608), password='password'),
User(name='Bart Simpson', email='bart@simpson.com', joined_at=datetime.datetime(2024, 12, 19, 16, 41, 38, 63184), id=UUID('418531a9-c114-4d16-8432-c2d7f899f237'), created_at=datetime.datetime(2024, 12, 19, 15, 41, 38, 66553), updated_at=datetime.datetime(2024, 12, 19, 15, 41, 38, 66583), password='password')]
Here we can see that we have forgot to set some `unique` values to our
fields and prevent duplicates. So let’s remove our duplicates manualy
now
First, we can use search to get all the records that contain some
character in some of their string fields. This is usefull for filtering
records where you’re not sure where the value shuld match.
``` python
users = User.search(search_value="Homer")
for user in users:
print(f"Name: {user.name} , Email: {user.email}, ID: {user.id}")
```
Name: Homer Simpson , Email: homer@simpson.com, ID: 4b3a4311-6103-4694-8954-d6771233bc97
Name: Homer Simpson , Email: homer.simpson@simpson.com, ID: fc724993-651f-47ea-a332-e2318e9c09a2
You can also set the fields you want to retreive from specific fields
using `fields` argument. This will now not return the instance of the
User rable but a list of tuples.
``` python
users = User.search(search_value="Simpson", fields=['name','email'])
users
```
[('Bart Simpson', 'bart@simpson.com'),
('Homer Simpson', 'homer@simpson.com'),
('Homer Simpson', 'homer.simpson@simpson.com')]
Now let’s retreive our records again
``` python
users = User.search(search_value="homer")
users
```
[User(name='Homer Simpson', email='homer@simpson.com', joined_at=datetime.datetime(2024, 12, 19, 16, 41, 37, 575422), id=UUID('4b3a4311-6103-4694-8954-d6771233bc97'), created_at=datetime.datetime(2024, 12, 19, 15, 41, 37, 589591), updated_at=datetime.datetime(2024, 12, 19, 15, 41, 37, 589608), password='password'),
User(name='Homer Simpson', email='homer.simpson@simpson.com', joined_at=datetime.datetime(2024, 12, 19, 16, 41, 32, 766940), id=UUID('fc724993-651f-47ea-a332-e2318e9c09a2'), created_at=datetime.datetime(2024, 12, 19, 15, 41, 32, 784370), updated_at=datetime.datetime(2024, 12, 19, 15, 41, 37, 952971), password='password')]
..and remove the first two results using the `delete` function
``` python
for user in users[:len(users)-1]:
user.delete()
for user in User.all():
print(user.name)
```
Homer Simpson
Bart Simpson
we also have the option to filter the records using `filter` function
for a specific model field.
``` python
results = User.filter(name="Homer Simpson")
results
```
[User(name='Homer Simpson', email='homer.simpson@simpson.com', joined_at=datetime.datetime(2024, 12, 19, 16, 41, 32, 766940), id=UUID('fc724993-651f-47ea-a332-e2318e9c09a2'), created_at=datetime.datetime(2024, 12, 19, 15, 41, 32, 784370), updated_at=datetime.datetime(2024, 12, 19, 15, 41, 37, 952971), password='password')]
``` python
results = User.filter(email="homer.simpson@simpson.com")
results
```
[User(name='Homer Simpson', email='homer.simpson@simpson.com', joined_at=datetime.datetime(2024, 12, 19, 16, 41, 32, 766940), id=UUID('fc724993-651f-47ea-a332-e2318e9c09a2'), created_at=datetime.datetime(2024, 12, 19, 15, 41, 32, 784370), updated_at=datetime.datetime(2024, 12, 19, 15, 41, 37, 952971), password='password')]
Similar to `search`, `filter` can take the same argumants, like
`fields`, `sorting_field` and other (for full list navigate to the db
section).
``` python
results = User.filter(name="Simp",exact_match=False,fields=["name","email"])
results
```
[('Bart Simpson', 'bart@simpson.com'),
('Homer Simpson', 'homer.simpson@simpson.com')]
We can also combine field filters.
``` python
results = User.filter(name="simp",email="hom",exact_match=False,fields=["name","email"])
results
```
[('Homer Simpson', 'homer.simpson@simpson.com')]
For more deatails visit related docs for
[SQLModel](https://sqlmodel.tiangolo.com/) and
[Alembic](https://alembic.sqlalchemy.org/en/latest/)
Raw data
{
"_id": null,
"home_page": "https://github.com/ndendic/FastSQLModel",
"name": "FastSQLModel",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": "nbdev jupyter notebook python",
"author": "Nikola Dendic",
"author_email": "Nikola Dendic <ndendic@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/06/20/0555a1035c284d7651fbb9dec75f8d37d081b09febfd7e52060ccd1f6856/fastsqlmodel-0.1.6.tar.gz",
"platform": null,
"description": "# FastSQLModel\n\n\n<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->\n\n## Overview\n\nFastSQLModel is a utility for simplifying the process of using\nSQLModel/SQLAlchemy and Alembic. It provides a CLI for initializing and\nmanaging Alembic migrations, and a set of tools for working with\nSQLModel and SQLAlchemy models.\n\n## Features\n\n- **CLI for Alembic**: FastSQLModel provides a CLI for initializing and\n managing Alembic migrations.\n- **SQLModel and SQLAlchemy Models**: FastSQLModel provides a set of\n tools for working with SQLModel and SQLAlchemy models.\n- **Database Management**: FastSQLModel provides a set of tools for\n managing the database, including creating, dropping, and querying the\n database.\n\n## Developer Guide\n\n### Install FastSQLModel in Development\n\nIf you want to make changes to the package, you can install it in\ndevelopment mode. This project uses nbdev for development, so you can\nmake changes to the code and documentation in the notebooks under the\nnbs/ directory. To find out more about amazing nbdev, visit the [nbdev\ndocumentation](https://nbdev.fast.ai/index.html).\n\nTo make changes to the package, you can install it in development mode.\n\n``` sh\n# make sure FastSQLModel package is installed in development mode\n$ pip install -e .\n\n# make changes under nbs/ directory\n# ...\n\n# compile to have changes apply to FastSQLModel\n$ nbdev_prepare\n```\n\n## Usage\n\n### Installation\n\nInstall latest from the GitHub\n[repository](https://github.com/ndendic/FastSQLModel):\n\n``` sh\n$ pip install git+https://github.com/ndendic/FastSQLModel.git\n```\n\nor from [conda](https://anaconda.org/ndendic/FastSQLModel)\n\n``` sh\n$ conda install -c ndendic FastSQLModel\n```\n\nor from [pypi](https://pypi.org/project/FastSQLModel/)\n\n``` sh\n$ pip install FastSQLModel\n```\n\nTo establish a connection to the database, please specify the\n`DATABASE_URL` in the `.env` file.\n\n### Documentation\n\nDocumentation can be found hosted on this GitHub\n[repository](https://github.com/ndendic/FastSQLModel)\u2019s\n[pages](https://ndendic.github.io/FastSQLModel/). Additionally you can\nfind package manager specific guidelines on\n[conda](https://anaconda.org/ndendic/FastSQLModel) and\n[pypi](https://pypi.org/project/FastSQLModel/) respectively.\n\n## How to use\n\n### Create your first model\n\nTo create your first model, you can can import the BaseTable class from\nthe FastSQLModel.db module and create a new model by subclassing it.\nBaseTable is a subclass of SQLModel, so it has all the same features,\nbut it also has a few extra features to help with some standard db\noperations and 3 extra fields: - id: primary key, default to a uuid4 -\ncreated_at: datetime, default to now - updated_at: datetime, default to\nnow, and updated on every save\n\n``` python\nclass BaseTable(SQLModel):\n model_config = ConfigDict(json_encoders={datetime: lambda dt: dt.isoformat()})\n id: UUID = Field(default_factory=uuid4, primary_key=True)\n created_at: datetime = Field(\n default_factory=utc_now,\n sa_type= sa.DateTime(timezone=True),\n sa_column_kwargs={\"server_default\": sa.func.now()},\n nullable=False,\n title=\"Created At\",\n schema_extra={\"icon\": \"clock\", \"input_type\": \"datetime\"},\n )\n updated_at: datetime = Field(\n default_factory=utc_now,\n sa_type=sa.DateTime(timezone=True),\n sa_column_kwargs={\n \"server_default\": sa.func.now(),\n \"server_onupdate\": sa.func.now(),\n },\n # onupdate=utc_now,\n nullable=False,\n title=\"Updated At\",\n schema_extra={\"icon\": \"clock\", \"input_type\": \"datetime\"},\n )\n```\n\nHere is an example of how to create a new model using BaseTable\n\n``` python\n# users.py\nfrom typing import Optional\nfrom sqlmodel import Field\nfrom datetime import datetime\nfrom FastSQLModel.db import BaseTable\n\nclass User(BaseTable, table=True):\n name: Optional[str] = Field(nullable=True)\n email: str = Field(nullable=False)\n password: str = Field(nullable=False)\n joined_at: datetime = Field(nullable=False)\n```\n\nNow that you have created your first model, you can use the CLI to\ninitialize and manage Alembic project.\n\n``` sh\n$ fastmodel init\n```\n\nThis will create a new Alembic project in the current directory, and\ncreate a new .alembic.ini file.\n\n2. Then make sure to add your models to the migrations/env.py file\n before running migrations.\n\n``` python\n# migrations/env.py\nfrom users import User\n# ...\n```\n\n3. Now you can run migrations to prepare the database for your models.\n\n``` sh\n$ fastmodel migrations\n```\n\n4. And now you can migrate your models to the database.\n\n``` sh\n$ fastmodel migrate\n```\n\nLet\u2019s see how this works\n\nInitialization:\n\n``` python\n# !fastmodel init\n```\n\n Successfully initialized Alembic in migrations directory!\n Please make sure to add your models to migrations/env.py file before running \n migrations!\n\nMaking migrations\n\n``` python\n!fastmodel migrations\n```\n\n Generating Alembic migration with message: Pushing changes\n DATABASE_URL sqlite:///test.db\n INFO [alembic.runtime.migration] Context impl SQLiteImpl.\n INFO [alembic.runtime.migration] Will assume non-transactional DDL.\n INFO [alembic.autogenerate.compare] Detected added table 'user'\n Generating /home/ndendic/WebDev/FastSQLModel/nbs/migrations/versions/4d9613e97\n da3_pushing_changes.py ... done\n Migration created successfully!\n\nMigrating changes\n\n``` python\n!fastmodel migrate\n```\n\n Applying database migrations...\n DATABASE_URL sqlite:///test.db\n INFO [alembic.runtime.migration] Context impl SQLiteImpl.\n INFO [alembic.runtime.migration] Will assume non-transactional DDL.\n INFO [alembic.runtime.migration] Running upgrade -> 4d9613e97da3, Pushing changes\n Migrations applied successfully!\n\nOnce our table is migrated, we can start adding some data like this.\n\n``` python\nuser = User(name=\"Homer Simpson\", email=\"homer@simpson.com\", password=\"password\", joined_at=datetime.now())\nuser.save()\nuser.model_dump()\n```\n\n {'name': 'Homer Simpson',\n 'email': 'homer@simpson.com',\n 'password': 'password',\n 'joined_at': datetime.datetime(2024, 12, 19, 16, 41, 37, 575422),\n 'id': UUID('4b3a4311-6103-4694-8954-d6771233bc97'),\n 'created_at': datetime.datetime(2024, 12, 19, 15, 41, 37, 576371, tzinfo=datetime.timezone.utc),\n 'updated_at': datetime.datetime(2024, 12, 19, 15, 41, 37, 576413, tzinfo=datetime.timezone.utc)}\n\nLet\u2019s get our user by id\n\n``` python\nhomer = User.get(user.id)\nif homer:\n print(f\"Name: {homer.name}, Email: {homer.email}\")\nelse:\n print(\"User not found\")\n```\n\n Name: Homer Simpson, Email: homer@simpson.com\n\nOr by alternative key value\n\n``` python\nhomer = User.get(\"homer@simpson.com\",alt_key=\"email\")\nif homer:\n print(f\"Name: {homer.name}, Email: {homer.email}\")\nelse:\n print(\"User not found\")\n```\n\n Name: Homer Simpson, Email: homer@simpson.com\n\nNow let\u2019s modify our record and save it back to our database and\nretreive back\n\n``` python\nhomer.email = \"homer.simpson@simpson.com\"\nhomer.save()\nhomer = User.get(\"homer.simpson@simpson.com\",alt_key=\"email\")\nhomer.email\n```\n\n 'homer.simpson@simpson.com'\n\nLet\u2019s define a bit more Simprons, this time like this\n\n``` python\nbart = User()\nbart.name = \"Bart Simpson\"\nbart.email = \"bart@simpson.com\"\nbart.password = \"password\"\nbart.joined_at = datetime.now()\nbart.save()\n\nbart.name, bart.email\n```\n\n ('Bart Simpson', 'bart@simpson.com')\n\nLet\u2019s retrive records in our table. We can simply do that by calling\n`all` function\n\n``` python\nUser.all()\n```\n\n [User(name='Homer Simpson', email='homer.simpson@simpson.com', joined_at=datetime.datetime(2024, 12, 19, 16, 41, 32, 766940), id=UUID('fc724993-651f-47ea-a332-e2318e9c09a2'), created_at=datetime.datetime(2024, 12, 19, 15, 41, 32, 784370), updated_at=datetime.datetime(2024, 12, 19, 15, 41, 37, 952971), password='password'),\n User(name='Homer Simpson', email='homer@simpson.com', joined_at=datetime.datetime(2024, 12, 19, 16, 41, 37, 575422), id=UUID('4b3a4311-6103-4694-8954-d6771233bc97'), created_at=datetime.datetime(2024, 12, 19, 15, 41, 37, 589591), updated_at=datetime.datetime(2024, 12, 19, 15, 41, 37, 589608), password='password'),\n User(name='Bart Simpson', email='bart@simpson.com', joined_at=datetime.datetime(2024, 12, 19, 16, 41, 38, 63184), id=UUID('418531a9-c114-4d16-8432-c2d7f899f237'), created_at=datetime.datetime(2024, 12, 19, 15, 41, 38, 66553), updated_at=datetime.datetime(2024, 12, 19, 15, 41, 38, 66583), password='password')]\n\nHere we can see that we have forgot to set some `unique` values to our\nfields and prevent duplicates. So let\u2019s remove our duplicates manualy\nnow\n\nFirst, we can use search to get all the records that contain some\ncharacter in some of their string fields. This is usefull for filtering\nrecords where you\u2019re not sure where the value shuld match.\n\n``` python\nusers = User.search(search_value=\"Homer\")\nfor user in users:\n print(f\"Name: {user.name} , Email: {user.email}, ID: {user.id}\")\n```\n\n Name: Homer Simpson , Email: homer@simpson.com, ID: 4b3a4311-6103-4694-8954-d6771233bc97\n Name: Homer Simpson , Email: homer.simpson@simpson.com, ID: fc724993-651f-47ea-a332-e2318e9c09a2\n\nYou can also set the fields you want to retreive from specific fields\nusing `fields` argument. This will now not return the instance of the\nUser rable but a list of tuples.\n\n``` python\nusers = User.search(search_value=\"Simpson\", fields=['name','email'])\nusers\n```\n\n [('Bart Simpson', 'bart@simpson.com'),\n ('Homer Simpson', 'homer@simpson.com'),\n ('Homer Simpson', 'homer.simpson@simpson.com')]\n\nNow let\u2019s retreive our records again\n\n``` python\nusers = User.search(search_value=\"homer\")\nusers\n```\n\n [User(name='Homer Simpson', email='homer@simpson.com', joined_at=datetime.datetime(2024, 12, 19, 16, 41, 37, 575422), id=UUID('4b3a4311-6103-4694-8954-d6771233bc97'), created_at=datetime.datetime(2024, 12, 19, 15, 41, 37, 589591), updated_at=datetime.datetime(2024, 12, 19, 15, 41, 37, 589608), password='password'),\n User(name='Homer Simpson', email='homer.simpson@simpson.com', joined_at=datetime.datetime(2024, 12, 19, 16, 41, 32, 766940), id=UUID('fc724993-651f-47ea-a332-e2318e9c09a2'), created_at=datetime.datetime(2024, 12, 19, 15, 41, 32, 784370), updated_at=datetime.datetime(2024, 12, 19, 15, 41, 37, 952971), password='password')]\n\n..and remove the first two results using the `delete` function\n\n``` python\nfor user in users[:len(users)-1]:\n user.delete()\n\nfor user in User.all():\n print(user.name)\n```\n\n Homer Simpson\n Bart Simpson\n\nwe also have the option to filter the records using `filter` function\nfor a specific model field.\n\n``` python\nresults = User.filter(name=\"Homer Simpson\")\nresults\n```\n\n [User(name='Homer Simpson', email='homer.simpson@simpson.com', joined_at=datetime.datetime(2024, 12, 19, 16, 41, 32, 766940), id=UUID('fc724993-651f-47ea-a332-e2318e9c09a2'), created_at=datetime.datetime(2024, 12, 19, 15, 41, 32, 784370), updated_at=datetime.datetime(2024, 12, 19, 15, 41, 37, 952971), password='password')]\n\n``` python\nresults = User.filter(email=\"homer.simpson@simpson.com\")\nresults\n```\n\n [User(name='Homer Simpson', email='homer.simpson@simpson.com', joined_at=datetime.datetime(2024, 12, 19, 16, 41, 32, 766940), id=UUID('fc724993-651f-47ea-a332-e2318e9c09a2'), created_at=datetime.datetime(2024, 12, 19, 15, 41, 32, 784370), updated_at=datetime.datetime(2024, 12, 19, 15, 41, 37, 952971), password='password')]\n\nSimilar to `search`, `filter` can take the same argumants, like\n`fields`, `sorting_field` and other (for full list navigate to the db\nsection).\n\n``` python\nresults = User.filter(name=\"Simp\",exact_match=False,fields=[\"name\",\"email\"])\nresults\n```\n\n [('Bart Simpson', 'bart@simpson.com'),\n ('Homer Simpson', 'homer.simpson@simpson.com')]\n\nWe can also combine field filters.\n\n``` python\nresults = User.filter(name=\"simp\",email=\"hom\",exact_match=False,fields=[\"name\",\"email\"])\nresults\n```\n\n [('Homer Simpson', 'homer.simpson@simpson.com')]\n\nFor more deatails visit related docs for\n[SQLModel](https://sqlmodel.tiangolo.com/) and\n[Alembic](https://alembic.sqlalchemy.org/en/latest/)\n",
"bugtrack_url": null,
"license": "Apache Software License 2.0",
"summary": "Simplie and Fast utility for SQLModel/SQLAlchemy and Alembic",
"version": "0.1.6",
"project_urls": {
"Homepage": "https://github.com/ndendic/FastSQLModel"
},
"split_keywords": [
"nbdev",
"jupyter",
"notebook",
"python"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "b4455d58fc1fc607c051bafe00fd06c0a52fa0d75fcdf540dd410c8a356f0c69",
"md5": "b396573ac64ac62060327684fb3ca219",
"sha256": "8b3c86924bba448c09bfaa3c3aea7e4d90b7e87a236c6f2cea02ad191868a329"
},
"downloads": -1,
"filename": "FastSQLModel-0.1.6-py3-none-any.whl",
"has_sig": false,
"md5_digest": "b396573ac64ac62060327684fb3ca219",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 20786,
"upload_time": "2024-12-19T20:12:19",
"upload_time_iso_8601": "2024-12-19T20:12:19.514226Z",
"url": "https://files.pythonhosted.org/packages/b4/45/5d58fc1fc607c051bafe00fd06c0a52fa0d75fcdf540dd410c8a356f0c69/FastSQLModel-0.1.6-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "06200555a1035c284d7651fbb9dec75f8d37d081b09febfd7e52060ccd1f6856",
"md5": "23bccd0c16c871d976cd925db9798dee",
"sha256": "d50a88e77e182d964517d9feadccd00f39720a77b4b6f30af6f9a953e900f44b"
},
"downloads": -1,
"filename": "fastsqlmodel-0.1.6.tar.gz",
"has_sig": false,
"md5_digest": "23bccd0c16c871d976cd925db9798dee",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 23955,
"upload_time": "2024-12-19T20:12:22",
"upload_time_iso_8601": "2024-12-19T20:12:22.032422Z",
"url": "https://files.pythonhosted.org/packages/06/20/0555a1035c284d7651fbb9dec75f8d37d081b09febfd7e52060ccd1f6856/fastsqlmodel-0.1.6.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-19 20:12:22",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "ndendic",
"github_project": "FastSQLModel",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "fastsqlmodel"
}