Project

General

Profile

DesignHistory » querydb.py

Script for querying a SQLite with FTS3 database - Adrian Georgescu, 08/29/2010 01:33 PM

 
#!/usr/bin/python2.6

import os
import re
import sqlite3
from datetime import datetime

conn = sqlite3.connect('data.db')
cursor = conn.cursor()

start = datetime.now()
cursor.execute('SELECT rowid, * FROM sip_trace WHERE packet MATCH "4a14e48dbc421d5b3521d1247fdb41871248e96f"')
data = []
while True:
rows = cursor.fetchmany()
if not rows:
break
for row in rows:
data.append(row)
end = datetime.now()
print len(data), (end-start)
conn.close()
(2-2/4)