{"by":"gwillen85","descendants":17,"id":45751339,"kids":[45751969,45751927,45751646,45756024,45824750],"score":35,"text":"I&#x27;ve been working on adding graph database capabilities to SQLite with support for the Cypher query language. As of this week, both CREATE and MATCH operations work with full relationship support.<p>Here&#x27;s what it looks like:<p><pre><code>    import sqlite3\n    conn = sqlite3.connect(&quot;:memory:&quot;)\n    conn.load_extension(&quot;.&#x2F;libgraph.so&quot;)\n    \n    conn.execute(&quot;CREATE VIRTUAL TABLE graph USING graph()&quot;)\n    \n    # Create a social network\n    conn.execute(&quot;&quot;&quot;SELECT cypher_execute(&#x27;\n        CREATE (alice:Person {name: &quot;Alice&quot;, age: 30}),\n               (bob:Person {name: &quot;Bob&quot;, age: 25}),\n               (alice)-[:KNOWS {since: 2020}]-&gt;(bob)\n    &#x27;)&quot;&quot;&quot;)\n    \n    # Query the graph with relationship patterns\n    conn.execute(&quot;&quot;&quot;SELECT cypher_execute(&#x27;\n        MATCH (a:Person)-[r:KNOWS]-&gt;(b:Person) \n        WHERE a.age &gt; 25 \n        RETURN a, r, b\n    &#x27;)&quot;&quot;&quot;)\n</code></pre>\nThe interesting part was building the complete execution pipeline - lexer, parser, logical planner, physical planner, and an iterator-based executor using the Volcano model. All in C99 with no dependencies beyond SQLite.<p>What works now:\n- Full CREATE: nodes, relationships, properties, chained patterns (70&#x2F;70 openCypher TCK tests)\n- MATCH with relationship patterns: (a)-[r:TYPE]-&gt;(b) with label and type filtering\n- WHERE clause: property comparisons on nodes (=, &gt;, &lt;, &gt;=, &lt;=, &lt;&gt;)\n- RETURN: basic projection with JSON serialization\n- Virtual table integration for mixing SQL and Cypher<p>Performance:\n- 340K nodes&#x2F;sec inserts (consistent to 1M nodes)\n- 390K edges&#x2F;sec for relationships\n- 180K nodes&#x2F;sec scans with WHERE filtering<p>Current limitations (alpha):\n- Only forward relationships (no `&lt;-[r]-` or bidirectional `-[r]-`)\n- No relationship property filtering in WHERE (e.g., `WHERE r.weight &gt; 5`)\n- No variable-length paths yet (e.g., `[r*1..3]`)\n- No aggregations, ORDER BY, property projection in RETURN\n- Must use double quotes for strings: {name: &quot;Alice&quot;} not {name: &#x27;Alice&#x27;}<p>This is alpha - API may change. But core graph query patterns work! The execution pipeline handles CREATE&#x2F;MATCH&#x2F;WHERE&#x2F;RETURN end-to-end.<p>Next up: bidirectional relationships, property projection, aggregations. Roadmap targets full Cypher support by Q1 2026.<p>Built as part of Agentflare AI, but it&#x27;s standalone and MIT licensed. Would love feedback on what to prioritize.<p>GitHub: <a href=\"https:&#x2F;&#x2F;github.com&#x2F;agentflare-ai&#x2F;sqlite-graph\" rel=\"nofollow\">https:&#x2F;&#x2F;github.com&#x2F;agentflare-ai&#x2F;sqlite-graph</a><p>Happy to answer questions about the implementation!","time":1761763966,"title":"Show HN: SQLite Graph Ext – Graph database with Cypher queries (alpha)","type":"story","url":"https://github.com/agentflare-ai/sqlite-graph"}