Пример #1
0
def set_engine(engine: str = "sqlite"):
    if engine == "postgres":
        db = PostgresEngine(config={"database": "piccolo_admin"})
    else:
        sqlite_path = os.path.join(os.path.dirname(__file__), "example.sqlite")
        db = SQLiteEngine(path=sqlite_path)

    for table_class in TABLE_CLASSES:
        table_class._meta._db = db
Пример #2
0
    def test_version_parsing(self):
        """
        Make sure the version number can correctly be parsed from a range
        of known formats.
        """
        self.assertEqual(
            PostgresEngine._parse_raw_version_string(version_string="9.4"),
            9.4)

        self.assertEqual(
            PostgresEngine._parse_raw_version_string(version_string="9.4.1"),
            9.4,
        )

        self.assertEqual(
            PostgresEngine._parse_raw_version_string(
                version_string="12.4 (Ubuntu 12.4-0ubuntu0.20.04.1)"),
            12.4,
        )
from piccolo.conf.apps import AppRegistry
from piccolo.engine.postgres import PostgresEngine

from settings import DB_HOST, DB_NAME, DB_PASSWORD, DB_PORT, DB_USER

DB = PostgresEngine(
    config={
        "database": DB_NAME,
        "user": DB_USER,
        "password": DB_PASSWORD,
        "host": DB_HOST,
        "port": DB_PORT,
    })

APP_REGISTRY = AppRegistry(apps=[
    "home.piccolo_app",
    "forum.piccolo_app",
    "piccolo_admin.piccolo_app",
])
Пример #4
0
from piccolo.engine.postgres import PostgresEngine
from piccolo.conf.apps import AppRegistry

DB = PostgresEngine({
    "host": "localhost",
    "database": "piccolo",
    "user": "******",
    "password": "******",
})

APP_REGISTRY = AppRegistry(apps=["tests.example_app.piccolo_app"])
Пример #5
0
import os

from piccolo.engine.postgres import PostgresEngine

DB = PostgresEngine(
    config={
        "host": os.environ.get("PG_HOST", "localhost"),
        "port": os.environ.get("PG_PORT", "5432"),
        "user": os.environ.get("PG_USER", "postgres"),
        "password": os.environ.get("PG_PASSWORD", ""),
        "database": os.environ.get("PG_DATABASE", "piccolo_api"),
    })
Пример #6
0
from piccolo.engine.postgres import PostgresEngine

from piccolo.conf.apps import AppRegistry

DB = PostgresEngine(
    config={
        "database": "piccolo_headless_blog",
        "user": "******",
        "password": "",
        "host": "localhost",
        "port": 5432,
    })

APP_REGISTRY = AppRegistry(
    apps=["blog.piccolo_app", "piccolo_admin.piccolo_app"])
Пример #7
0
import os
import sys

from piccolo.conf.apps import AppRegistry
from piccolo.engine.postgres import PostgresEngine

# Modify the path, so piccolo_api is available
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(__file__))))

DB = PostgresEngine(
    config={
        "database": "piccolo_api_captcha",
        "user": "******",
        "password": "",
        "host": "localhost",
        "port": 5432,
    }
)

APP_REGISTRY = AppRegistry(
    apps=[
        "piccolo.apps.user.piccolo_app",
        "piccolo_api.session_auth.piccolo_app",
    ]
)