Oh nice!! Will this be called in the context of the same thread
executing the sql? This would allow me to debug without formatting all
debugs I believe...
I was not offended personally, however I was annoyed that a
conversation on a topic that I felt helpful to the community was
being shut down.
When I shared the response I got the feedback was that the
received answer fell under was the umbrella of "mansplainining"
and how a response such as that is problematic and explained why
folks are turned off to tech, it certainly factors into my
weariness with engaging with various communities out there.
It's not that I have any doubt of my skills, but that in the way
they were called out was problematic because it shifted the topic
from solving a problem to a question about the skillset of the
person presenting the problem. That was the cause of irritation.
The only offense taken was that my time was wasted and that
further research into the problem was being brushed aside by
questioning skill rather than looking into the actual problem
presented.
Anyhow, I found something useful, and I will be looking at making it more generally useful and hopefully sharing with the community.
Adding a snippet like this to my app was very helpful, however I'm wondering if there's something I'm missing that may cause a catastrophe?
I'm looking at maybe making it useful for detecting if a new
piece of code happens to also cause more then "N" queries to
suddenly happen, making the app slow.
Is there maybe a better way?
thanks,
-Alfred
+++ b/jetbridge/models/quiz_attempt.py
@@ -84,12 +84,21 @@ class QuizAttempt(JBModel, db.Model):
query = query.options(jl)
return query
+ def new_score_before_cursor_execute(self, conn, cursor,
statement, parameters, context, executemany):
+ log.info("quiz_attempt id: {} ".format(self.id))
+ log.info("vvvvvvvvvvvvvvvvvvv\nNEW_SCORE: Received
statement: %s\n^^^^^^^^^^^^^^^^^^\n", statement)
+
+
def new_score(self, question_id=None, question=None):
"""The new scoring system.
Returns a triple (total_score, base_score, timer_bonus)
"""
_log_scores("Called new_score")
+ from sqlalchemy import event
+ listen_obj = db.session.connection()
+ fun = self.new_score_before_cursor_execute
+ event.listen(listen_obj, "before_cursor_execute", fun)
table = dict()
"""
@@ -143,6 +152,7 @@ class QuizAttempt(JBModel, db.Model):
log.debug("loops = {}".format(loops))
log.debug("score: {} (base: {}, timer_bonus:
{})".format(total_score, base_score, timer_bonus))
"""
+ event.remove(listen_obj, "before_cursor_execute", fun)
return {
"score_total": total_score,
"score_base": base_score,
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
http://www.sqlalchemy.org/
To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description.
---
You received this message because you are subscribed to a topic in the Google Groups "sqlalchemy" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sqlalchemy/W2c5LmCcnww/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sqlalchemy+...@googlegroups.com.
This approach can also be made extremely performant by making sure you
load up that profile datafile just once, and cache it in memory in a
dictionary.