示例#1
0
 async def _submit_new_event(self, memo_dict):
     answer = 'New event was successfully created 🎉'
     await telegram_bot.send_message(chat_id=self.chat.user_id, text=answer)
     # Save to database
     create_event(
         db=next(get_db()),
         title=memo_dict['title'],
         start=memo_dict['start'],
         end=memo_dict['end'],
         content=memo_dict['content'],
         owner_id=self.user.id,
         location=memo_dict['location'],
     )
     # Delete current session
     del telegram_bot.MEMORY[self.chat.user_id]
     return answer
示例#2
0
 def test_get_db(self):
     assert isinstance(next(get_db()), Session)
示例#3
0
import os

from app import create_app
from app.database.database import get_db

config_name = os.getenv('CONFIG')
app = create_app(config_name)

if __name__ == '__main__':
    if config_name == 'DEVELOPMENT':
        host = '127.0.0.1'
        port = 5000
    else:
        host = '0.0.0.0'
        port = 80

    app.run(host=host, port=port)
    # Connect to database at least one to avoid cold start
    get_db()
示例#4
0
 def test_session_db():
     assert get_db() is not None
示例#5
0
文件: main.py 项目: nir9696/calendar
create_tables(engine, PSQL_ENVIRONMENT)

app = FastAPI()
app.mount("/static", StaticFiles(directory=STATIC_PATH), name="static")
app.mount("/media", StaticFiles(directory=MEDIA_PATH), name="media")
app.logger = logger

# This MUST come before the app.routers imports.
set_ui_language()

from app.routers import (  # noqa: E402
    agenda, calendar, categories, currency, dayview, email, event, invitation,
    profile, search, telegram, whatsapp)

json_data_loader.load_to_db(next(get_db()))

routers_to_include = [
    agenda.router,
    calendar.router,
    categories.router,
    currency.router,
    dayview.router,
    email.router,
    event.router,
    invitation.router,
    profile.router,
    search.router,
    telegram.router,
    whatsapp.router,
]