Switch to sqlite3, use parametized queries (field = ?), and send ping on connect.