How to connect UiPath Studio to SQLite .db file?

Hi all,

I have a .db file. I want to connect that .db file to UiPath to get data from it by executing SQL statements. How can I do this?

Thanks,
Harmeet

Hi @harmeet_kaur

Have a look on the thread

Regards
Gokul

Thanks for sharing. How can I create DSN for my .db file to use it in the connection activity in UIPath?

1 Like

Hi @harmeet_kaur

Have a look on the thread

Regards
Gokul

Working Solution tested in UiPath Studio 24.10.5 with System.Data.SQLite.1.0.119 from https://api.nuget.org/v3/index.json for a Windows project compatibility

  1. Install the System.Data.SQLite.1.0.119 dependency in your project in Manage Packages ribbon

  2. Copy the “C:\Users\robot_username.nuget\packages\stub.system.data.sqlite.core.netstandard\1.0.119\runtimes\win-x64\native\SQLite.Interop.dll” file to Studio/Robot installation folder

  3. Add an Invoke Code activity for CSharp language

try
{
    string connectionString = "Data Source=C:\\Users\\robot_username\\Documents\\UiPath\\ExtractPDT_Test\\REPLACE_WITH_DATABASE_FILE_NAME.db;Version=3;";

    using (System.Data.SQLite.SQLiteConnection conn = new System.Data.SQLite.SQLiteConnection(connectionString)) 
    {
        conn.Open();
        
        string sql = "SELECT * FROM REPLACE_WITH_TABLE_NAME";
        using (System.Data.SQLite.SQLiteCommand command = new System.Data.SQLite.SQLiteCommand(sql, conn)) 
        {
            using (System.Data.SQLite.SQLiteDataReader reader = command.ExecuteReader())
            {
                    DataTable dt = new System.Data.DataTable();
                    dt.Load(reader);
                    query_output = dt;
            }
        }
    }
}
catch (Exception e)
{
    string error = e.Message;
	error_output = error;
}

Results after execution:

1 Like