My project utils package, that I use in my projects.
Project description
Dev utils
For what?
I made this project to avoid copy-pasting with utils in my projects. I was aiming to simplify working with sqlalchemy, FastAPI and other libs.
Profiling
Profiling utils. Now available 2 profilers and 2 middlewares (FastAPI) for such profilers:
- SQLAlchemyQueryProfiler - profile entire sqlalchemy query - it text, params, duration.
- SQLAlchemyQueryCounter - count sqlalchemy queries.
SQLAlchemy Filters
Converters for SQLAlchemy filters. Now available 3 converters:
- Simple filter converter (key-value with equals operator).
- Advanced filter converter (key-value with custom operators).
- Django filter converter (Django filters adapter with double underscore lookups).
Filters must be provided in a dict or list or dicts and will be applied sequentially.
Simple filters
Simple filters are simle. There are key
- value
dicts (you can use one dict with all filters,
or list of dicts. There is no difference), which converts to SQLAlchemy filters with ==
operator.
filter_spec = [
{'field_name_1': 123, 'field_name_2': 'value'},
{'other_name_1': 'other_name', 'other_name_2': 123},
# ...
]
No other specific usages presents. it is simple.
Advanced filters
Advanced filters continues the idea of simple-filter, but add operator key.
This is the list of operators that can be used:
=
>
<
>
'<=
is
is_not
between
contains
Django filters
Django filters implements django ORM adapter for filters.
Now implements all field filters, except nester models.
This is the list of operators that can be used:
exact
iexact
contains
icontains
in
gt
gte
lt
lte
startswith
istartswith
endswith
iendswith
range
date
year
iso_year
month
day
week
week_day
iso_week_day
quarter
time
hour
minute
second
isnull
regex
iregex
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for python_dev_utils-1.0.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 330236454e75a9c60742b68c0d74ac8e4d38a110821de38c158cf262caa158e7 |
|
MD5 | 2584c478d9e53fc958a0d134515b718d |
|
BLAKE2b-256 | 585342b926b24af56755004a1c5298ca9fa17f9b06f537dc6880c4a71f4512ae |