Create your own driver for System.Data.Common

Background:

Our C # application generates and executes queries against several types of databases (Oracle, SQL Server, MySQL), but we also needed to apply them to the proprietary file format.

  • The namespace used so far is System.Data.Common.
  • The queries we need to apply are non-trivial (nested SELECTs, aliases in FROM, substring and string concatenation methods)

First, we converted the contents of the proprietary file to CSV, for which there is a driver {Microsoft Text Driver (* .txt; * .csv)} . However, the client required that temporary files not be created, and everything should happen in memory.

Creating an ODBC driver to directly query a file seems too demanding. So, we are considering the possibility of creating a driver (possibly ODBC), in which we will "implement" the SQLite ODBC driver. Inside this driver, we can load the contents of the CSV files into the in-memory database, and then redirect the request to the internal ODBC driver.

My questions:

  • Could this decision be feasible?
  • Where to start to create an ODBC driver from scratch?

thanks

+3
source share
4 answers

SQLite - , , ADO.NET SQLite, System. Data.SQLite.


, , ODBC ADO.NET (System.Data.Odbc). , ODBC - ( C- , , , ).

- ( - SQL ): ADO.NET, (, , . providerName). , ADO.NET.

SQLite , ADO.NET, SQLite DB. : .NET.

+1

If you are only limited to creating temporary files, you can try using SQLite mode in memory. Here's a sample connection string for it ( source ):

Data Source=:memory:;Version=3;New=True;

In my opinion, this is easier than creating a full-blown provider. $

0
source

Source: https://habr.com/ru/post/1719501/


All Articles