From 93657770c7e52b87566760e45fc1948bf9fe82f0 Mon Sep 17 00:00:00 2001
From: ali <ali.sayyah2@gmail.com>
Date: Tue, 25 Jan 2022 21:40:36 +0330
Subject: [PATCH] added piccolo_conf.py

---
 .../db_piccolo/piccolo_conf.py                | 22 +++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100644 fastapi_template/template/{{cookiecutter.project_name}}/{{cookiecutter.project_name}}/db_piccolo/piccolo_conf.py

diff --git a/fastapi_template/template/{{cookiecutter.project_name}}/{{cookiecutter.project_name}}/db_piccolo/piccolo_conf.py b/fastapi_template/template/{{cookiecutter.project_name}}/{{cookiecutter.project_name}}/db_piccolo/piccolo_conf.py
new file mode 100644
index 0000000..ebcc586
--- /dev/null
+++ b/fastapi_template/template/{{cookiecutter.project_name}}/{{cookiecutter.project_name}}/db_piccolo/piccolo_conf.py
@@ -0,0 +1,22 @@
+from piccolo.conf.apps import AppRegistry
+
+from {{cookiecutter.project_name}}.settings import settings
+
+{%- if cookiecutter.db_info.name == "postgresql" %}
+from piccolo.engine.postgres import PostgresEngine
+
+DB = PostgresEngine(config={'host': settings.db_host,
+                            'port': settings.db_port,
+                            'user': settings.db_user,
+                            'password': settings.db_pass,
+                            'database': settings.db_base})
+
+{%- elif cookiecutter.db_info.name == "sqlite" %}
+from piccolo.engine.sqlite import SQLiteEngine
+
+DB = SQLiteEngine(path=settings.db_file)
+{%- endif %}
+
+# A list of paths to piccolo apps
+# e.g. ['blog.piccolo_app']
+APP_REGISTRY = AppRegistry(apps=[])
-- 
GitLab