
* ✨ Add UUID support from sqlalchemy 2.0 update * ⚰️ Remove dead code for GUID old support * 📝 Add documentation for UUIDs * 🧪 Add test for UUIDs field definition and support * 🎨 [pre-commit.ci] Auto format from pre-commit.com hooks * ✏️ Fix prerequisites docs for uuid * ♻️ Update UUID source examples for consistency Keep consistency with other examples, functions without parameters, and printing info that shows and explains the UUID results (and can also be tested later) * 📝 Add source examples for selecting UUIDs with session.get() * 📝 Re-structure UUID docs * Explain the concepts at the beggining before using them. * Explain how UUIDs can be used and trusted. * Explain why UUIDs could be generated on the code, and how they can be used for distributed systems. * Explain how UUIDs can prevent information leakage. * Warn about UUIDs storage size. * Explain that uuid is part of the standard library. * Explain how default_factory works. * Explain that creating an instance would generate a new UUID, before it is sent to the DB. This is included and shown in the example, the UUID is printed before saving to the DB. * Remove sections about other operations that would behave the same as other fields and don't need additional info from what was explained in previous chapters. * Add two examples to select using UUIDs, similar to the previous ones, mainly to be able to use them in the tests and ensure that it all works, even when SQLite stores the values as strings but the where() or the session.get() receive UUID values (ensure SQLAlchemy does the conversion correctly for SQLite). * Add an example terminal run of the code, with comments. * Simplify the ending to keep only the information that wasn't there before, just the "Learn More" with links. * ✅ Refactor tests with new printed code, extract and check that UUIDs are used in the right places. * ✅ Add tests for the new extra UUID examples, for session.get() * 🎨 [pre-commit.ci] Auto format from pre-commit.com hooks * 📝 Rename variable in example for Python 3.7+ for consistency with 3.10+ (I missed that change before) --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
144 lines
6.6 KiB
Python
144 lines
6.6 KiB
Python
__version__ = "0.0.19"
|
|
|
|
# Re-export from SQLAlchemy
|
|
from sqlalchemy.engine import create_engine as create_engine
|
|
from sqlalchemy.engine import create_mock_engine as create_mock_engine
|
|
from sqlalchemy.engine import engine_from_config as engine_from_config
|
|
from sqlalchemy.inspection import inspect as inspect
|
|
from sqlalchemy.pool import QueuePool as QueuePool
|
|
from sqlalchemy.pool import StaticPool as StaticPool
|
|
from sqlalchemy.schema import BLANK_SCHEMA as BLANK_SCHEMA
|
|
from sqlalchemy.schema import DDL as DDL
|
|
from sqlalchemy.schema import CheckConstraint as CheckConstraint
|
|
from sqlalchemy.schema import Column as Column
|
|
from sqlalchemy.schema import ColumnDefault as ColumnDefault
|
|
from sqlalchemy.schema import Computed as Computed
|
|
from sqlalchemy.schema import Constraint as Constraint
|
|
from sqlalchemy.schema import DefaultClause as DefaultClause
|
|
from sqlalchemy.schema import FetchedValue as FetchedValue
|
|
from sqlalchemy.schema import ForeignKey as ForeignKey
|
|
from sqlalchemy.schema import ForeignKeyConstraint as ForeignKeyConstraint
|
|
from sqlalchemy.schema import Identity as Identity
|
|
from sqlalchemy.schema import Index as Index
|
|
from sqlalchemy.schema import MetaData as MetaData
|
|
from sqlalchemy.schema import PrimaryKeyConstraint as PrimaryKeyConstraint
|
|
from sqlalchemy.schema import Sequence as Sequence
|
|
from sqlalchemy.schema import Table as Table
|
|
from sqlalchemy.schema import UniqueConstraint as UniqueConstraint
|
|
from sqlalchemy.sql import LABEL_STYLE_DEFAULT as LABEL_STYLE_DEFAULT
|
|
from sqlalchemy.sql import (
|
|
LABEL_STYLE_DISAMBIGUATE_ONLY as LABEL_STYLE_DISAMBIGUATE_ONLY,
|
|
)
|
|
from sqlalchemy.sql import LABEL_STYLE_NONE as LABEL_STYLE_NONE
|
|
from sqlalchemy.sql import (
|
|
LABEL_STYLE_TABLENAME_PLUS_COL as LABEL_STYLE_TABLENAME_PLUS_COL,
|
|
)
|
|
from sqlalchemy.sql import alias as alias
|
|
from sqlalchemy.sql import bindparam as bindparam
|
|
from sqlalchemy.sql import column as column
|
|
from sqlalchemy.sql import delete as delete
|
|
from sqlalchemy.sql import except_ as except_
|
|
from sqlalchemy.sql import except_all as except_all
|
|
from sqlalchemy.sql import exists as exists
|
|
from sqlalchemy.sql import false as false
|
|
from sqlalchemy.sql import func as func
|
|
from sqlalchemy.sql import insert as insert
|
|
from sqlalchemy.sql import intersect as intersect
|
|
from sqlalchemy.sql import intersect_all as intersect_all
|
|
from sqlalchemy.sql import join as join
|
|
from sqlalchemy.sql import lambda_stmt as lambda_stmt
|
|
from sqlalchemy.sql import lateral as lateral
|
|
from sqlalchemy.sql import literal as literal
|
|
from sqlalchemy.sql import literal_column as literal_column
|
|
from sqlalchemy.sql import modifier as modifier
|
|
from sqlalchemy.sql import null as null
|
|
from sqlalchemy.sql import nullsfirst as nullsfirst
|
|
from sqlalchemy.sql import nullslast as nullslast
|
|
from sqlalchemy.sql import outerjoin as outerjoin
|
|
from sqlalchemy.sql import outparam as outparam
|
|
from sqlalchemy.sql import table as table
|
|
from sqlalchemy.sql import tablesample as tablesample
|
|
from sqlalchemy.sql import text as text
|
|
from sqlalchemy.sql import true as true
|
|
from sqlalchemy.sql import union as union
|
|
from sqlalchemy.sql import union_all as union_all
|
|
from sqlalchemy.sql import update as update
|
|
from sqlalchemy.sql import values as values
|
|
from sqlalchemy.types import ARRAY as ARRAY
|
|
from sqlalchemy.types import BIGINT as BIGINT
|
|
from sqlalchemy.types import BINARY as BINARY
|
|
from sqlalchemy.types import BLOB as BLOB
|
|
from sqlalchemy.types import BOOLEAN as BOOLEAN
|
|
from sqlalchemy.types import CHAR as CHAR
|
|
from sqlalchemy.types import CLOB as CLOB
|
|
from sqlalchemy.types import DATE as DATE
|
|
from sqlalchemy.types import DATETIME as DATETIME
|
|
from sqlalchemy.types import DECIMAL as DECIMAL
|
|
from sqlalchemy.types import DOUBLE as DOUBLE
|
|
from sqlalchemy.types import DOUBLE_PRECISION as DOUBLE_PRECISION
|
|
from sqlalchemy.types import FLOAT as FLOAT
|
|
from sqlalchemy.types import INT as INT
|
|
from sqlalchemy.types import INTEGER as INTEGER
|
|
from sqlalchemy.types import JSON as JSON
|
|
from sqlalchemy.types import NCHAR as NCHAR
|
|
from sqlalchemy.types import NUMERIC as NUMERIC
|
|
from sqlalchemy.types import NVARCHAR as NVARCHAR
|
|
from sqlalchemy.types import REAL as REAL
|
|
from sqlalchemy.types import SMALLINT as SMALLINT
|
|
from sqlalchemy.types import TEXT as TEXT
|
|
from sqlalchemy.types import TIME as TIME
|
|
from sqlalchemy.types import TIMESTAMP as TIMESTAMP
|
|
from sqlalchemy.types import UUID as UUID
|
|
from sqlalchemy.types import VARBINARY as VARBINARY
|
|
from sqlalchemy.types import VARCHAR as VARCHAR
|
|
from sqlalchemy.types import BigInteger as BigInteger
|
|
from sqlalchemy.types import Boolean as Boolean
|
|
from sqlalchemy.types import Date as Date
|
|
from sqlalchemy.types import DateTime as DateTime
|
|
from sqlalchemy.types import Double as Double
|
|
from sqlalchemy.types import Enum as Enum
|
|
from sqlalchemy.types import Float as Float
|
|
from sqlalchemy.types import Integer as Integer
|
|
from sqlalchemy.types import Interval as Interval
|
|
from sqlalchemy.types import LargeBinary as LargeBinary
|
|
from sqlalchemy.types import Numeric as Numeric
|
|
from sqlalchemy.types import PickleType as PickleType
|
|
from sqlalchemy.types import SmallInteger as SmallInteger
|
|
from sqlalchemy.types import String as String
|
|
from sqlalchemy.types import Text as Text
|
|
from sqlalchemy.types import Time as Time
|
|
from sqlalchemy.types import TupleType as TupleType
|
|
from sqlalchemy.types import TypeDecorator as TypeDecorator
|
|
from sqlalchemy.types import Unicode as Unicode
|
|
from sqlalchemy.types import UnicodeText as UnicodeText
|
|
from sqlalchemy.types import Uuid as Uuid
|
|
|
|
# From SQLModel, modifications of SQLAlchemy or equivalents of Pydantic
|
|
from .main import Field as Field
|
|
from .main import Relationship as Relationship
|
|
from .main import SQLModel as SQLModel
|
|
from .orm.session import Session as Session
|
|
from .sql.expression import all_ as all_
|
|
from .sql.expression import and_ as and_
|
|
from .sql.expression import any_ as any_
|
|
from .sql.expression import asc as asc
|
|
from .sql.expression import between as between
|
|
from .sql.expression import case as case
|
|
from .sql.expression import cast as cast
|
|
from .sql.expression import col as col
|
|
from .sql.expression import collate as collate
|
|
from .sql.expression import desc as desc
|
|
from .sql.expression import distinct as distinct
|
|
from .sql.expression import extract as extract
|
|
from .sql.expression import funcfilter as funcfilter
|
|
from .sql.expression import not_ as not_
|
|
from .sql.expression import nulls_first as nulls_first
|
|
from .sql.expression import nulls_last as nulls_last
|
|
from .sql.expression import or_ as or_
|
|
from .sql.expression import over as over
|
|
from .sql.expression import select as select
|
|
from .sql.expression import tuple_ as tuple_
|
|
from .sql.expression import type_coerce as type_coerce
|
|
from .sql.expression import within_group as within_group
|
|
from .sql.sqltypes import AutoString as AutoString
|