implement general composition in ComposableMapper subtype
This commit is contained in:
6
examples/.ipynb_checkpoints/database-checkpoint.ipynb
Normal file
6
examples/.ipynb_checkpoints/database-checkpoint.ipynb
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"cells": [],
|
||||
"metadata": {},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
||||
57
examples/database.ipynb
Normal file
57
examples/database.ipynb
Normal file
@@ -0,0 +1,57 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"id": "6f6fbc7e-4fb9-4353-b2ee-9ea819a3c896",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"/home/smgr/.pyenv/versions/co4/lib/python3.12/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
|
||||
" from .autonotebook import tqdm as notebook_tqdm\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import vegetables"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "88fd0ea8-9c94-4569-a51b-823a04f32f55",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"tomato = vegetables.Tomato('t1', 5)\n",
|
||||
"\n",
|
||||
"# test a register collation action\n",
|
||||
"tomato.collate('ripe')"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "co3",
|
||||
"language": "python",
|
||||
"name": "co3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.12.2"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
||||
@@ -103,3 +103,25 @@ tomato_cooking_table = sa.Table(
|
||||
vegetable_schema = SQLSchema.from_metadata(metadata)
|
||||
vegetable_mapper = Mapper(vegetable_schema)
|
||||
|
||||
def attr_name_map(cls):
|
||||
return f'{cls.__name__.lower()}'
|
||||
|
||||
def coll_name_map(cls, action_group):
|
||||
return f'{cls.__name__.lower()}_{action_group}_states'
|
||||
|
||||
vegetable_mapper.attach_many(
|
||||
type_list,
|
||||
attr_name_map,
|
||||
coll_name_map,
|
||||
)
|
||||
|
||||
'''
|
||||
new mapping type for Mapper attachment:
|
||||
|
||||
Callable[ [type[CO3], str|None], tuple[str, tuple[str], tuple[str]]]
|
||||
|
||||
tail tuples to associate column names from central table to collation
|
||||
|
||||
this should complete the auto-compose horizontally
|
||||
'''
|
||||
|
||||
|
||||
Reference in New Issue
Block a user