Commit e390703a authored by delanoe's avatar delanoe

[FIX] SQL POOL: closing after executed.

parent 00949019
......@@ -171,3 +171,5 @@ def bulk_insert_ifnotexists(model, uniquekey, fields, data, cursor=None, do_stat
cursor.execute('COMMIT WORK;')
cursor.close()
......@@ -177,6 +177,7 @@ def compute_ti_ranking(corpus,
- overwrite_id: optional id of a pre-existing XXXX node for this corpus
(the Node and its previous Node NodeNgram rows will be replaced)
"""
print("compute_ti_ranking")
# validate string params
if count_scope not in ["local","global"]:
raise ValueError("compute_ti_ranking: count_scope param allowed values: 'local', 'global'")
......@@ -371,7 +372,7 @@ def compute_ti_ranking(corpus,
# TODO 2 release these 2 typenames TFIDF-CORPUS and TFIDF-GLOBAL
# TODO 3 recreate them elsewhere in their sims (WeightedIndex) version
# TODO 4 requalify this here as a NodeNgram
# then TODO 5 use WeightedList.save() !
# TODO 5 use WeightedList.save()
# reflect that in NodeNodeNgrams
bulk_insert(
......
......@@ -3,7 +3,7 @@ COOCS
(this is the full SQL version, should be more reliable on outerjoin)
"""
from gargantext import settings
from sqlalchemy import create_engine
from sqlalchemy import create_engine, exc
from gargantext.util.lists import WeightedMatrix
# from gargantext.util.db import session, aliased, func
from gargantext.util.db_cache import cache
......@@ -223,10 +223,19 @@ def compute_coocs( corpus,
# 6) EXECUTE QUERY
# ----------------
# debug
print(final_sql)
#print(final_sql)
# executing the SQL statement
results = connection.execute(final_sql)
try:
# suppose the database has been restarted.
results = connection.execute(final_sql)
connection.close()
except exc.DBAPIError as e:
# an exception is raised, Connection is invalidated.
if e.connection_invalidated:
print("Connection was invalidated for ngram_coocs")
else:
print(e)
# => storage in our matrix structure
matrix = WeightedMatrix(results)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment