MCPcopy Index your code

hub / github.com/tortoise/tortoise-orm / functions

Functions3,850 in github.com/tortoise/tortoise-orm

↓ 1,473 callersMethodcreate
Create a record in the DB and returns the object. .. code-block:: python3 user = await User.create(name="...", email=".
tortoise/models.py:1364
↓ 662 callersMethodget
Fetches a single record for a Model type using the provided filter parameters. .. code-block:: python3 user = await Use
tortoise/models.py:1557
↓ 566 callersMethodfilter
Generates a QuerySet with the filter applied. :param args: Q functions containing constraints. Will be AND'ed. :param kwargs
tortoise/models.py:1503
↓ 404 callersMethodall
Returns the complete QuerySet.
tortoise/models.py:1550
↓ 235 callersMethodvalues
(self)
tortoise/apps.py:335
↓ 224 callersMethodannotate
Annotates the result set with extra Functions/Aggregations/Expressions. :param kwargs: Parameter name and the Function/Aggregation t
tortoise/models.py:1541
↓ 174 callersMethodvalues_list
Make QuerySet returns list of tuples for given args instead of objects. If call after `.get()`, `.get_or_none()` or `.first()` retur
tortoise/queryset.py:653
↓ 164 callersMethodfirst
Generates a QuerySet that returns the first record.
tortoise/models.py:1489
↓ 155 callersMethodadd
Adds one or more of ``instances`` to the relation. If it is already added, it will be silently ignored. :raises Operational
tortoise/fields/relational.py:177
↓ 150 callersMethodsave
Creates/Updates the current model object. :param update_fields: If provided, it should be a tuple/list of fields by name.
tortoise/models.py:1130
↓ 142 callersMethoditems
(self)
tortoise/apps.py:338
↓ 127 callersMethodorder_by
Accept args to filter by in format like this: .. code-block:: python3 .order_by('name', '-tournament__name') S
tortoise/queryset.py:467
↓ 123 callersMethodupdate
Update all objects in QuerySet with given kwargs. .. admonition: Example: .. code-block:: py3 await Em
tortoise/queryset.py:758
↓ 99 callersMethodinit
Sets up Tortoise-ORM: loads apps and models, configures database connections but does not connect to the database yet. The actual con
tortoise/__init__.py:297
↓ 78 callersMethod_qualify_table_name
(self, table_name: str, schema: str | None = None)
tortoise/schema_quoting.py:34
↓ 73 callersMethodcount
Return count of objects in queryset instead of objects.
tortoise/queryset.py:781
↓ 73 callersFunctionpydantic_model_creator
Function to build `Pydantic Model <https://docs.pydantic.dev/latest/concepts/models/>`__ off Tortoise Model. :param cls: The Tortoise Model
tortoise/contrib/pydantic/creator.py:600
↓ 69 callersMethodsql
Returns the SQL query that will be executed. By default, it will return the query with placeholders, but if you set `params_inline=Tr
tortoise/queryset.py:298
↓ 61 callersMethodfetch_related
Fetch related fields. .. code-block:: python3 User.fetch_related("emails", "manager") :param args: The related
tortoise/models.py:1211
↓ 61 callersFunctionget_by_data_filter
(obj, **kwargs)
tests/contrib/postgres/test_json.py:12
↓ 60 callersFunctionin_transaction
Transaction context manager. You can run your code inside ``async with in_transaction():`` statement to run it into one transaction. If
tortoise/transactions.py:33
↓ 56 callersFunctionq
Quote an identifier for the given dialect.
tests/migrations/test_operations_real_db.py:76
↓ 55 callersFunction_reset_tortoise
Helper to reset Tortoise state before each test. Note: We MUST NOT set Tortoise.apps = None or Tortoise._inited = False because these are cla
tests/schema/test_generate_schema.py:104
↓ 55 callersFunction_teardown_tortoise
Helper to teardown Tortoise state after each test.
tests/schema/test_generate_schema.py:135
↓ 53 callersMethodconstruct
Create a model instance without validation, DB checks, or FK restrictions. This creates a "detached" instance that has the right sha
tortoise/models.py:942
↓ 50 callersMethodget_for_dialect
Returns a field by dialect override. :param dialect: The requested SQL Dialect. :param key: The attribute/method name.
tortoise/fields/base.py:428
↓ 49 callersMethodprefetch_related
Like ``.fetch_related()`` on instance, but works on all objects in QuerySet. :raises FieldError: If the field to prefetch on is not
tortoise/queryset.py:1016
↓ 48 callersMethodrun
( self, app_label: str, state: State, dry_run: bool, state_editor: Bas
tortoise/migrations/operations.py:44
↓ 47 callersMethod_run_sql
Execute DDL SQL. Subclasses may override for backend-specific handling. If ``collect_sql`` is True, append the SQL to ``collected_sql`` inste
tortoise/migrations/schema_editor/base.py:66
↓ 47 callersMethodonly
Fetch ONLY the specified fields to create a partial model. Persisting changes on the model is allowed only when: * All the
tortoise/queryset.py:956
↓ 42 callersMethodgenerate_schemas
Generate schemas according to models provided to ``.init()`` method. Will fail if schemas already exists, so it's not recommended to
tortoise/__init__.py:513
↓ 40 callersFunctionbuild_state
(app_label: str, *models: type[Model])
tests/migrations/test_state_diff_operations.py:35
↓ 39 callersFunctionget_current_context
Get the currently active TortoiseContext, or None if no context is active. Checks the contextvar first (for proper isolation), then falls ba
tortoise/context.py:55
↓ 39 callersFunctionget_schema_sql
Generates the SQL schema for the given client. :param client: The DB client to generate Schema SQL for :param safe: When set to true, cr
tortoise/utils.py:24
↓ 39 callersMethodkeys
(self)
tortoise/apps.py:341
↓ 37 callersMethoddb
(self)
tortoise/models.py:291
↓ 36 callersMethodhas_db_default
(self)
tortoise/fields/base.py:345
↓ 36 callersFunctionmake_model
( model_name: str, table: str, meta_options: Mapping[str, Any] | None = None, /, **model_f
tests/migrations/test_state_diff_operations.py:42
↓ 35 callersMethodgroup_by
Make QuerySet returns list of dict or tuple with group by. Must call before .values() or .values_list()
tortoise/queryset.py:643
↓ 34 callersMethoddescribe
Describes the given list of models or ALL registered models. :param serializable: ``False`` if you want raw python objec
tortoise/models.py:1694
↓ 33 callersMethodget_model
(self, app_label: str, model_name: str | None = None)
tortoise/migrations/schema_generator/state_apps.py:133
↓ 33 callersMethodget_sql
(self, ctx: SqlContext)
tortoise/filters.py:51
↓ 32 callersMethodexecute_script
(self, query: str)
tests/migrations/test_recorder.py:13
↓ 32 callersFunctionexpand_db_url
(db_url: str, testing: bool = False)
tortoise/backends/base/config_generator.py:165
↓ 31 callersMethodbulk_create
Bulk insert operation: .. note:: The bulk insert operation will do the minimum to ensure that the object cre
tortoise/models.py:1438
↓ 30 callersMethodalter_field
( self, old_model: type[Model], new_model: type[Model], field_name: str )
tortoise/migrations/schema_editor/base.py:689
↓ 30 callersMethodlimit
Limits QuerySet to given length. :raises ParamsError: Limit should be non-negative number.
tortoise/queryset.py:517
↓ 30 callersMethodstate_forward
(self, app_label: str, state: State)
tests/migrations/test_runtime_migrations.py:348
↓ 29 callersMethodget_model
(self, app_label: str, model_name: str)
tortoise/apps.py:310
↓ 28 callersMethodexecute_query
(self, query: str, values: list | None = None)
tests/utils/fake_client.py:41
↓ 28 callersMethodfrom_tortoise_orm
Returns a serializable pydantic model instance built from the provided model instance. .. note:: This will prefetch all
tortoise/contrib/pydantic/base.py:76
↓ 28 callersMethodgenerate
(self, app_labels: Sequence[str] | None = None)
tortoise/migrations/schema_generator/operation_generator.py:120
↓ 28 callersFunctionrun_async
Simple async runner that cleans up DB connections on exit. This is meant for simple scripts. Usage:: from tortoise import Torto
tortoise/__init__.py:555
↓ 28 callersMethodto_db_value
Converts from the Python type to the DB type. :param value: Current python value in model. :param instance: Model class or M
tortoise/fields/base.py:298
↓ 27 callersFunction_reset_tortoise
Helper to reset Tortoise state before each test. Note: We MUST NOT set Tortoise.apps = None or Tortoise._inited = False because these are cla
tests/model_setup/test_init.py:16
↓ 26 callersMethoddelete
Deletes the current model object. :param using_db: Specific DB connection to use instead of default bound :raises Operation
tortoise/models.py:1196
↓ 26 callersMethodexists
Return True/False whether record exists with the provided filter parameters. .. code-block:: python3 result = await Use
tortoise/models.py:1591
↓ 25 callersMethodexecute_query_dict
(self, query: str, values: list | None = None)
tests/utils/fake_client.py:50
↓ 25 callersMethodquote
(val: str)
tortoise/schema_quoting.py:31
↓ 24 callersMethodresolve
(self, resolve_context: ResolveContext)
tortoise/expressions.py:131
↓ 21 callersMethodregister_model
(self, app_label: str, model: type[Model])
tortoise/migrations/schema_generator/state_apps.py:29
↓ 20 callersFunction_init_for_sqlite
Initialize Tortoise for SQLite and return SQL statements.
tests/schema/test_generate_schema.py:157
↓ 20 callersMethodas_
(self, alias: str)
tortoise/expressions.py:238
↓ 20 callersMethodearliest
Generates a QuerySet with the filter applied that returns the first record. :params orderings: Fields to order by.
tortoise/models.py:1522
↓ 20 callersMethodexecute_query
(self, query: str, values: list | None = None)
tortoise/backends/odbc/client.py:138
↓ 20 callersMethodlatest
Generates a QuerySet with the filter applied that returns the last record. :params orderings: Fields to order by.
tortoise/models.py:1513
↓ 19 callersMethod_clone
(self)
tortoise/queryset.py:375
↓ 19 callersMethodget_or_none
Fetches a single record for a Model type using the provided filter parameters or None. .. code-block:: python3 user = a
tortoise/models.py:1608
↓ 19 callersMethodremove
Removes one or more of ``instances`` from the relation. :raises OperationalError: remove() was called with no instances.
tortoise/fields/relational.py:228
↓ 18 callersFunction_get_sql
Get SQL statement containing the given text.
tests/schema/test_generate_schema.py:147
↓ 18 callersFunction_write_package
(tmp_path: Path, name: str)
tests/cli/test_cli.py:37
↓ 18 callersMethodcreate_model
(self, model: type[Model])
tortoise/migrations/schema_editor/base.py:468
↓ 17 callersFunction_make_schema_models
Build models with Meta.schema='custom' for testing.
tests/migrations/test_schema_qualified_migrations.py:59
↓ 17 callersMethodget_parameterized_sql
(self, ctx: SqlContext | None = None)
tortoise/backends/psycopg/client.py:48
↓ 16 callersFunction_run_cli
(args: list[str])
tests/cli/test_cli.py:67
↓ 16 callersFunction_write_settings
(tmp_path: Path, content: str, module_name: str)
tests/cli/test_cli.py:62
↓ 16 callersFunctionexecute_pypika
( query: QueryBuilder, *, using_db: BaseDBAsyncClient | None = None, schema: None = None, )
tortoise/query_api.py:56
↓ 16 callersMethodresolve
Resolves the logical Q chain into the parts of a SQL statement. :param model: The Model this Q Expression should be resolved on.
tortoise/expressions.py:498
↓ 15 callersMethod_choose_db_if_not_chosen
(self, for_write: bool = False)
tortoise/queryset.py:130
↓ 15 callersFunction_get_option_list
(model_state: ModelState, key: str)
tortoise/migrations/operations.py:634
↓ 15 callersMethodadd_field
(self, name: str, value: Field)
tortoise/models.py:267
↓ 15 callersMethodexecute_script
(self, query: str)
tortoise/backends/odbc/client.py:161
↓ 15 callersMethodget_table
Return a PyPika table for this model.
tortoise/models.py:808
↓ 15 callersFunctionmake_model
( model_name: str, *, meta_options: dict[str, Any] | None = None, **model_fields: Field, )
tests/migrations/test_operations_database.py:44
↓ 15 callersFunctiontortoise_test_context
Async context manager for isolated test database setup. This is the recommended way to set up Tortoise ORM for testing with pytest. Each
tortoise/context.py:526
↓ 14 callersMethod__init__
( self: IntField[int], primary_key: bool | None = None, *, null: Literal[False
tortoise/fields/data.py:105
↓ 14 callersMethod_get_storage
Get the connection storage dict for the current task context.
tortoise/connection.py:64
↓ 14 callersFunctionbuild_state
(app_label: str, model: type)
tests/migrations/test_operations_database.py:58
↓ 14 callersFunctionget_connections
Get the ConnectionHandler from the current context. This is a convenience function. Prefer accessing connections directly via context: `
tortoise/connection.py:330
↓ 14 callersMethodoffset
Query offset for QuerySet. :raises ParamsError: Offset should be non-negative number.
tortoise/queryset.py:530
↓ 14 callersFunctionparse_timezone
(zone: str)
tortoise/timezone.py:26
↓ 14 callersMethodstate_forward
(self, app_label: str, state: State)
tortoise/migrations/operations.py:170
↓ 14 callersMethodto_dict
(self)
tortoise/config.py:79
↓ 13 callersMethod_combine
(self, other: Any, connector: Connector, right_hand: bool)
tortoise/expressions.py:180
↓ 13 callersFunction_make_model
Create a model class dynamically for migration tests.
tests/fields/test_db_default.py:391
↓ 13 callersMethod_quote
(self, name: str)
tortoise/migrations/recorder.py:21
↓ 13 callersMethod_resolve_fields_to_columns
Resolve model field names to database column names. For FK fields like 'organization', returns the DB column 'organization_id'. For r
tortoise/migrations/schema_editor/base.py:748
↓ 13 callersMethodclear
Clears ALL relations.
tortoise/fields/relational.py:222
↓ 13 callersMethodset
Sets the given alias to the provided connection object for the current task. :param conn_alias: The alias to set the connection for.
tortoise/connection.py:195
↓ 12 callersFunction_field_signature
(field: Field)
tortoise/migrations/schema_generator/state_diff.py:65
next →1–100 of 3,850, ranked by callers