Commit 40f1ab97 authored by mouadh's avatar mouadh

improve code

parent 19490d30
...@@ -44,11 +44,8 @@ class StringFolder(object): ...@@ -44,11 +44,8 @@ class StringFolder(object):
# Look up the unicode value in the map and return # Look up the unicode value in the map and return
# the object from the map. If there is no matching entry, # the object from the map. If there is no matching entry,
# store this unicode object in the map and return it. # store this unicode object in the map and return it.
t = self.unicode_map.get(s, None) return self.unicode_map.setdefault(s, s)
if t is None:
# Put s in the map
t = self.unicode_map[s] = s
return t
def string_folding_wrapper(results): def string_folding_wrapper(results):
""" """
...@@ -82,9 +79,7 @@ def _load_tables_db(executer_instance): ...@@ -82,9 +79,7 @@ def _load_tables_db(executer_instance):
# 'SELECT * FROM "{0}"'.format(table_name), db.engine) # 'SELECT * FROM "{0}"'.format(table_name), db.engine)
# results = db.engine.execute('SELECT * FROM "{0}"'.format(table_name)) # results = db.engine.execute('SELECT * FROM "{0}"'.format(table_name))
results = (db.engine results = db.engine.execution_options(stream_results=True).execute('SELECT * FROM "{0}"'.format(table_name))
.execution_options(stream_results=True)
.execute('SELECT * FROM "{0}"'.format(table_name)))
# Fetch all the results of the query # Fetch all the results of the query
# value = pd.DataFrame(iter(results),columns=results.keys()) # Pass results as an iterator # value = pd.DataFrame(iter(results),columns=results.keys()) # Pass results as an iterator
value = pd.DataFrame(string_folding_wrapper(results),columns=results.keys()) value = pd.DataFrame(string_folding_wrapper(results),columns=results.keys())
......
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