This commit is contained in:
parent
523cb1f467
commit
253970094b
2 changed files with 35 additions and 0 deletions
12
app/hysql.hy
Normal file
12
app/hysql.hy
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
#!/usr/bin/env hy
|
||||||
|
(import app [models])
|
||||||
|
(import app.database [async_session])
|
||||||
|
(import sqlalchemy [select])
|
||||||
|
(import pprint [pprint])
|
||||||
|
|
||||||
|
|
||||||
|
(defn/a selete_object
|
||||||
|
[db ap_type]
|
||||||
|
(.all (await (.scalars db
|
||||||
|
(.where (select models.InboxObject)
|
||||||
|
(= models.InboxObject.ap_type ap_type))))))
|
23
tasks.py
23
tasks.py
|
@ -202,3 +202,26 @@ def send_note(ctx):
|
||||||
print("Done!")
|
print("Done!")
|
||||||
|
|
||||||
asyncio.run(_dodo())
|
asyncio.run(_dodo())
|
||||||
|
|
||||||
|
|
||||||
|
@task
|
||||||
|
def get_object(ctx, ap_type):
|
||||||
|
import hy
|
||||||
|
from app.database import async_session
|
||||||
|
from app.hysql import selete_object
|
||||||
|
from pprint import pprint
|
||||||
|
|
||||||
|
async def _dodo():
|
||||||
|
async with async_session() as db_session: #type: ignore
|
||||||
|
|
||||||
|
return await selete_object(
|
||||||
|
db_session,
|
||||||
|
ap_type
|
||||||
|
)
|
||||||
|
|
||||||
|
res = asyncio.run(_dodo())
|
||||||
|
for ap_object in res:
|
||||||
|
print("=====")
|
||||||
|
print(ap_object.id )
|
||||||
|
print(ap_object.ap_id)
|
||||||
|
pprint(ap_object.ap_object)
|
||||||
|
|
Loading…
Reference in a new issue