def sort_obsid_from_sqlite(sqlite_file):
"""
"""
import sqlite3 as dbdrv
obs_dict = defaultdict(int)
query = "SELECT DISTINCT(obs_id) FROM ac WHERE offline > -1 ORDER BY obs_id"
dbconn = dbdrv.connect(sqlite_file)
cur = dbconn.cursor()
cur.execute(query)
all_obs = cur.fetchall() # not OK if we have millions of obs numbers
cur.close()
for c, obsid_row in enumerate(all_obs):
obs_dict[obsid_row[0]] = c + 1
return (obs_dict, all_obs[0][0], all_obs[-1][0])
评论列表
文章目录