Replies: 2 comments 7 replies
-
Thanks for the heads up, sugizo. Sure, if you share your code in a repository it might be interesting to have a link here. Thanks! |
Beta Was this translation helpful? Give feedback.
-
I mean the parts that interact with a database: rows = db(query).select().as_json()
# ...
row = db(db[tablename]._id == rec_id).validate_and_update(**values)
db.commit()
# ...
row = db(db[tablename]._id == rec_id).delete()
db.commit() Right now the methods are all synchronous. Since interacting with a db is a I/O bound operation, these methods should all be asynchronous. As a side note, I described this in my documentation:
I know little about If you want to learn more about the async pattern, I recommend to watch Ryan Dahl's original presentation of Node.js. Notes:
For example, instead of: @app.route('/api/get/{tablename}/{rec_id}', methods = ['GET'] )
def get(request, tablename, rec_id):
query = (db[tablename]['id'] == rec_id)
rows = db(query).select().as_json()
return responses.text(rows) Something like: @app.route('/api/get/{tablename}/{rec_id}', methods = ['GET'] )
async def get(request, tablename, rec_id):
query = (db[tablename]['id'] == rec_id)
rows = await db(query).select() # Note the await!
return responses.text(rows.as_json()) |
Beta Was this translation helpful? Give feedback.
-
successful implement blacksheep with pydal
could share or documented if you interest
posted some of code on here
thanks
Beta Was this translation helpful? Give feedback.
All reactions