Skip to content

Dynamic Table creation and mapping #904

Closed Answered by dantownsend
AsfanUlla asked this question in Q&A
Discussion options

You must be logged in to vote

Piccolo lets you specify which schema a table lives in:

class MyTable(Table, schema='schema_1'):
    my_column = Varchar()

If you potentially have many schemas (one for each customer) you can create table classes at run time using this:

piccolo/piccolo/table.py

Lines 1358 to 1387 in 5f972d0

def create_table_class(
class_name: str,
bases: t.Tuple[t.Type] = (Table,),
class_kwargs: t.Dict[str, t.Any] = {},
class_members: t.Dict[str, t.Any] = {},
) -> t.Type[Table]:
"""
Used to dynamically create ``Table``subclasses at runtime. Most users
will not require this. It's mostly used internally for Piccolo's
migrations.
:param …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by dantownsend
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants