● Zion Boggan
repos/Docket/services/ingest/_check_summaries.py
zionboggan.com ↗
15 lines · python
History for this file →
1
import sqlite3
2
c = sqlite3.connect('/opt/docket/data/docket.db')
3
c.execute('PRAGMA busy_timeout=30000')
4
c.row_factory = sqlite3.Row
5
total = c.execute("SELECT COUNT(*) FROM bills WHERE source='legiscan'").fetchone()[0]
6
withs = c.execute("SELECT COUNT(*) FROM bills WHERE source='legiscan' AND summary IS NOT NULL AND summary<>''").fetchone()[0]
7
print("legiscan total:", total, "with_summary:", withs)
8
rows = c.execute("""SELECT jurisdiction, COUNT(*) n FROM bills
9
    WHERE source='legiscan' AND summary IS NOT NULL AND summary<>''
10
    GROUP BY jurisdiction ORDER BY n DESC LIMIT 20""").fetchall()
11
print("by state:", [(r['jurisdiction'], r['n']) for r in rows])
12
samp = c.execute("""SELECT jurisdiction, number, substr(summary,1,120) s, summary_source
13
    FROM bills WHERE source='legiscan' AND summary IS NOT NULL AND summary<>'' LIMIT 5""").fetchall()
14
for r in samp:
15
    print("SAMPLE", r['jurisdiction'], r['number'], '|', r['summary_source'], '|', r['s'])