Take a lock for a sqlite3 session