Ejemplo n.º 1
0
import asyncio

from utils.db_api.postgresql import Database


async def setup_psql():
    await db.create()


loop = asyncio.get_event_loop()
db = Database()

loop.run_until_complete(db.select_all_users())
import asyncio
from utils.db_api.postgresql import Database


async def test():
    await db.create_table_news()
    # await db.add_news(user_id=1, content='Test', photo_id='Test', caption='Test', username='******')
    # await db.add_news(user_id=2, content='Test', photo_id='Test', caption='Test', username='******')
    # await db.add_news(user_id=3, content='Test', photo_id='Test', caption='Test', username='******')
    # await db.add_news(user_id=4, content='Test', photo_id='Test', caption='Test', username='******')
    # news = await db.select_all_news()
    # print(news[0])
    news = await db.select_one_news(id=2)
    print(news)


loop = asyncio.get_event_loop()
db = Database(loop)

loop.run_until_complete(test())
Ejemplo n.º 3
0
from aiogram import Bot, Dispatcher, types
from aiogram.contrib.fsm_storage.memory import MemoryStorage

from data import config
from utils.db_api.postgresql import Database

bot = Bot(token=config.BOT_TOKEN, parse_mode=types.ParseMode.HTML)
storage = MemoryStorage()
dp = Dispatcher(bot, storage=storage)
db = Database(loop=dp.loop)