JordanMarr / SqlHydra

SqlHydra is a suite of NuGet packages for working with databases in F# including code generation tools and query expressions.
MIT License
212 stars 20 forks source link

dotnet sqlhydra sqlite fails #56

Closed AngelMunoz closed 1 year ago

AngelMunoz commented 1 year ago

Hey there, I want to give this a spin for an embedded db to keep track of a few things in one of my projects and I wanted to give it a try in a console application first to get familiar with it

I Installed SQLHydra.Cli locally in a clean .net7 console project and as the readme suggests and ran it but I seem to get an exception.

dotnet sqlhydra sqlite
daniel@ubuntu:~/shared/repos/Sqoldo$ dotnet sqlhydra sqlite
- SqlHydra.Sqlite
- v2.0.0.0
- `sqlhydra-sqlite.toml` does not exist. Starting configuration wizard...
- Enter a database Connection String: sample.db
- Enter an Output Filename (Ex: AdventureWorks.fs): SqoldoData.fs
- Enter a Namespace (Ex: MyApp.AdventureWorks): Sqoldo.Data
- Select a use case: SqlHydra.Query integration (default)
- sqlhydra-sqlite.toml has been created!
- Please install the `System.Data.SQLite` NuGet package in your project.
- Please install the `SqlHydra.Query` NuGet package in your project.
Unhandled exception: System.DllNotFoundException: Unable to load shared library 'SQLite.Interop.dll'....

I'm not sure if there's something else going to be performed by the CLI but each time I run the command it happens again

Full Exception ``` daniel@ubuntu:~/shared/repos/Sqoldo$ dotnet sqlhydra sqlite - SqlHydra.Sqlite - v2.0.0.0 - `sqlhydra-sqlite.toml` does not exist. Starting configuration wizard... - Enter a database Connection String: sample.db - Enter an Output Filename (Ex: AdventureWorks.fs): SqoldoData.fs - Enter a Namespace (Ex: MyApp.AdventureWorks): Sqoldo.Data - Select a use case: SqlHydra.Query integration (default) - sqlhydra-sqlite.toml has been created! - Please install the `System.Data.SQLite` NuGet package in your project. - Please install the `SqlHydra.Query` NuGet package in your project. Unhandled exception: System.DllNotFoundException: Unable to load shared library 'SQLite.Interop.dll' or one of its dependencies. In order to help diagnose loading problems, consider using a tool like strace. If you're using glibc, consider setting the LD_DEBUG environment variable: /home/daniel/.dotnet/shared/Microsoft.NETCore.App/7.0.5/SQLite.Interop.dll.so: cannot open shared object file: No such file or directory /home/daniel/.nuget/packages/sqlhydra.cli/2.0.0/tools/net7.0/any/SQLite.Interop.dll.so: cannot open shared object file: No such file or directory /home/daniel/.dotnet/shared/Microsoft.NETCore.App/7.0.5/libSQLite.Interop.dll.so: cannot open shared object file: No such file or directory /home/daniel/.nuget/packages/sqlhydra.cli/2.0.0/tools/net7.0/any/libSQLite.Interop.dll.so: cannot open shared object file: No such file or directory /home/daniel/.dotnet/shared/Microsoft.NETCore.App/7.0.5/SQLite.Interop.dll: cannot open shared object file: No such file or directory /home/daniel/.nuget/packages/sqlhydra.cli/2.0.0/tools/net7.0/any/SQLite.Interop.dll: cannot open shared object file: No such file or directory /home/daniel/.dotnet/shared/Microsoft.NETCore.App/7.0.5/libSQLite.Interop.dll: cannot open shared object file: No such file or directory /home/daniel/.nuget/packages/sqlhydra.cli/2.0.0/tools/net7.0/any/libSQLite.Interop.dll: cannot open shared object file: No such file or directory at System.Data.SQLite.UnsafeNativeMethods.sqlite3_config_none(SQLiteConfigOpsEnum op) at System.Data.SQLite.SQLite3.StaticIsInitialized() at System.Data.SQLite.SQLiteLog.PrivateInitialize(String className) at System.Data.SQLite.SQLiteLog.Initialize(String className) at System.Data.SQLite.SQLiteConnection..ctor(String connectionString, Boolean parseViaFramework) at System.Data.SQLite.SQLiteConnection..ctor(String connectionString) at SqlHydra.Sqlite.SqliteSchemaProvider.getSchema(Config cfg) in C:\_github\SqlHydra\src\SqlHydra.Cli\Sqlite\SqliteSchemaProvider.fs:line 14 at SqlHydra.Program.handler@12-2.Invoke(Config cfg) at SqlHydra.Console.run(Args args) in C:\_github\SqlHydra\src\SqlHydra.Cli\Console.fs:line 140 at SqlHydra.Program.handler(String provider, FSharpOption`1 tomlFile) in C:\_github\SqlHydra\src\SqlHydra.Cli\Program.fs:line 25 at SqlHydra.Program.main@35.Invoke(Tuple`2 tupledArg) at FSharp.SystemCommandLine.CommandBuilders.SetHandlerUnit@163-2.Invoke(InvocationContext ctx) at System.CommandLine.Invocation.AnonymousCommandHandler.Invoke(InvocationContext context) at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_0.<b__0>d.MoveNext() --- End of stack trace from previous location --- at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass17_0.<b__0>d.MoveNext() --- End of stack trace from previous location --- at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass12_0.<b__0>d.MoveNext() --- End of stack trace from previous location --- at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass22_0.<b__0>d.MoveNext() --- End of stack trace from previous location --- at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass19_0.<b__0>d.MoveNext() --- End of stack trace from previous location --- at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<b__18_0>d.MoveNext() --- End of stack trace from previous location --- at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass16_0.<b__0>d.MoveNext() --- End of stack trace from previous location --- at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<b__5_0>d.MoveNext() --- End of stack trace from previous location --- at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass8_0.<b__0>d.MoveNext() ```
JordanMarr commented 1 year ago

Oh no! Sorry that was your first experience. It seems to be failing at the point where the sqlite query begins. I’ll take a look.

JordanMarr commented 1 year ago

I think I see your issue. For the connection string, you entered the file name, but you actually have to enter it in this format:

Data Source=C:\_mdsk\BenjaminMoore.ColorWeb\Product\Source\WebUI\wwwroot\data\ProductSelector.sqlite;Version=3;UseUTF16Encoding=True;

However, having just tried it out myself, it certainly would be convenient for SQLite if it was possible to just enter the db filename and then have it automatically generate a connection string for you. 🤔

AngelMunoz commented 1 year ago

Hey there sorry I just got back to this, I fear that the error you found is a different one than mine:

Unhandled exception: System.ArgumentException: Invalid ConnectionString format for part "sample.db", no equal sign found

But after adding the connection string how it should go it worked fine!

The error I was having was due to a missing dependency in the OS (The project is running on a Raspberry Pi) I cloned the project in Fedora/Windows and I was unable to reproduce so I will close this, thanks!


However, having just tried it out myself, it certainly would be convenient for SQLite if it was possible to just enter the db filename and then have it automatically generate a connection string for you. :thinking:

I think as a feedback item I'd say you could:

In both cases you can still have "connection" to provide a full connection string for customization.

That being said, probably when the wizard is running (or the docs/readme) can just clarify that you're expecting a connection string rather than just the name!