2 ms·
The meat of the P/Invoke code is in here: https://github.com/electroly/sqlnotebook/tree/master/src/SqlNotebookScript/Core/SqliteInterop https://github.com/elect
by electroly 3y ago
The meat of the P/Invoke code is in here: https://github.com/electroly/sqlnotebook/tree/master/src/SqlNotebookScript/Core/SqliteInterop https://github.com/electroly/sqlnotebook/tree/master/src/Sql...
The parent directory includes code that uses it. I'm most proud of this SQLite virtual table module that proxies queries to remote ADO.NET connections, allowing you to write joins directly between local SQLite tables and remote SQL Server tables. https://github.com/electroly/sqlnotebook/blob/master/src/SqlNotebookScript/Core/AdoModules/AdoModuleProvider.cs https://github.com/electroly/sqlnotebook/blob/master/src/Sql...
This is exposed to the user as a "LINK" option on the "IMPORT DATABASE" statement: https://sqlnotebook.com/import-database-stmt.html https://sqlnotebook.com/import-database-stmt.html
I've also got a generic virtual table module that lets me easily write table-valued functions in C#: https://github.com/electroly/sqlnotebook/blob/master/src/SqlNotebookScript/Core/GenericModules/GenericModuleProvider.cs https://github.com/electroly/sqlnotebook/blob/master/src/Sql...
I don't have too many table-valued functions yet but one example is the "LIST_XLS_WORKSHEETS" function: https://sqlnotebook.com/list-xls-worksheets-func.html https://sqlnotebook.com/list-xls-worksheets-func.html
I have my own implementation of SQLite's grammar so I can embed it inside my larger grammar which adds things like DECLARE, IF, and WHILE: https://github.com/electroly/sqlnotebook/blob/master/src/SqlNotebookScript/Interpreter/SqliteGrammar.cs https://github.com/electroly/sqlnotebook/blob/master/src/Sql...
The goal is to provide various "supercharged" features to base SQLite by taking advantage of all the extension points I can. I wish some went further; in particular the virtual table API doesn't "push down" enough of the original query to allow the module to avoid doing N+1 queries in some cases.
Always happy to see people using SQLite in unique ways!
- ncruces 3y agoOh I wanted to implement a virtual table to do the same thing in Go (access a remote DB, with where clause push down). Will have a look at your code!