Replies: 1 comment 5 replies
-
|
@XCanG Piccolo has the concept of an apps to separate code into separate logical units. In your case (if I understand correctly) you need one central application (called a tree
.
├── backend
│ ├── __init__.py
│ ├── main.py
│ └── piccolo_app.py
├── db
│ ├── __init__.py
│ ├── piccolo_app.py
│ ├── piccolo_migrations
│ │ ├── db_2025_08_11t07_30_57_292674.py
│ │ └── __init__.py
│ └── tables.py
├── integration1
│ ├── __init__.py
│ ├── main.py
│ └── piccolo_app.py
├── main.py
└── piccolo_conf.pyAs you can see, only the from piccolo.conf.apps import AppConfig
APP_CONFIG = AppConfig(
app_name="backend", # or app_name="integration1"
migrations_folder_path="",
)Now you can import from db.piccolo_app import APP_CONFIG
from db.tables import Task
task_tables = APP_CONFIG.table_classes
tasks = Task.select().run_sync()Then put the main input file from backend.main import task_tables, tasks
from integration1.main import tables_columns
print(tasks)
print(task_tables)
print(tables_columns)I hope this helps and I apologize if I didn't get your point. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I have a project with FastAPI backend and integration bots, they all share the same model files from a root project, however when I tried to add Piccolo integration I immediately stumbled upon those Apps and that those apps has to be unique. If I use one name for them then I get error like
ValueError: There are 2 apps with the nameapp. This can cause unexpected behavior. Make sure each app has a unique name, and you haven't registered the same app multiple times.But if I use different name then I get duplicate migrations, e.g. I make a migration with:
piccolo migrations new app --autoI get one file with all tables, then when I do check it shows me multiple entries for the same migration.My project structure is like that:
My
piccolo_app.pyhave this app config:Root folder db have models file with shared models, the same config duplicated in other integrations with exception of
app_name.I need a way to import Piccolo everywhere, but I don't need separate migrations and duplicates.
Beta Was this translation helpful? Give feedback.
All reactions