Query Construction
Make the filter condition as much complicate as you want. But may get some improvement in rewriting in the future to improve efficiency.
The naming of variables are important for multiple queries, actually several variables you use to construct the conditions are equivalant in their position. For example, SELECT C.* FROM streets C,streets D,streets E WHERE C.B=D.A AND D.B=E.A AND E.B=C.A; will give you all edges that cause the cycle, not just the single edge you indicate in the writing forms.
Interesting concurrency problem
Sqlite is light-weight database, and only support Locks based on Library level, thus not approraited to High concurrency situation. Each time only supports 1 write operation. If 2 process try to write at the same time will get you DB is locked.