params = {
...
'reply_markup': {
'inline_keyboard': [[
{'text': '', 'callback_data': '/pic_vote 0'},
{'text': '', 'callback_data': '/pic_vote 1'}
]]
}
}
async def some_coro(engine: aiopg.sa.Engine):
async with engine.acquire() as conn:
await conn.execute(query)
loop = asyncio.get_event_loop()
engine = loop.run_until_complete(aiopg.sa.create_engine(db_url, loop=loop))
loop.run_until_complete(some_coro(engine=engine))
engine.close()
loop.run_until_complete(engine.wait_closed())
class Category(models.Model):
parent = models.ForeignKey('self', null=True)
title = models.CharField(...)
class Product(models.Model):
title = models.CharField(...)
parent = models.ManyToManyField('self', null=True)
# in class Category
is_best = models.Boolean(default=False)
cursor.execute("INSERT OR IGNORE INTO t1 (col1, col2, col3) VALUES (? ? ?)", (col1, col2, col3))
def foo():
foo()
class Bar():
def foo(self, ...):
pass
class Foo(Bar):
...
def foo(self, ...):
super(Foo, self).foo(...)
pass
class Foo(models.Model):
...
pass
@receiver(post_save, sender=Foo)
def foo_bar(sender, instance, **kwargs):
instance.save()