diff --git a/src/frontend/config/sidebar/integrations.topics.ts b/src/frontend/config/sidebar/integrations.topics.ts index 7916f562..b9e76082 100644 --- a/src/frontend/config/sidebar/integrations.topics.ts +++ b/src/frontend/config/sidebar/integrations.topics.ts @@ -586,7 +586,24 @@ export const integrationTopics: StarlightSidebarTopicsUserConfig = { }, ], }, - { label: 'SQLite', slug: 'integrations/databases/sqlite' }, + { + label: 'SQLite', + collapsed: true, + items: [ + { + label: 'Get started', + slug: 'integrations/databases/sqlite/sqlite-get-started', + }, + { + label: 'Hosting integration (AppHost)', + slug: 'integrations/databases/sqlite/sqlite-host', + }, + { + label: 'Client integration (Your app)', + slug: 'integrations/databases/sqlite/sqlite-client', + }, + ], + }, { label: 'SurrealDB', slug: 'integrations/databases/surrealdb' }, ], }, diff --git a/src/frontend/src/content/docs/integrations/databases/sqlite.mdx b/src/frontend/src/content/docs/integrations/databases/sqlite.mdx deleted file mode 100644 index 6a8036f7..00000000 --- a/src/frontend/src/content/docs/integrations/databases/sqlite.mdx +++ /dev/null @@ -1,159 +0,0 @@ ---- -title: SQLite integration -description: Learn how to use the SQLite integration for efficient data management within your applications. -next: false ---- - -import { Aside } from '@astrojs/starlight/components'; -import { Badge } from '@astrojs/starlight/components'; -import InstallPackage from '@components/InstallPackage.astro'; -import InstallDotNetPackage from '@components/InstallDotNetPackage.astro'; -import { Image } from 'astro:assets'; -import sqliteIcon from '@assets/icons/sqlite-icon.png'; - - - -SQLite logo - -[SQLite](https://www.sqlite.org/index.html) is a lightweight, serverless, self-contained SQL database engine that is widely used for local data storage in applications. The Aspire SQLite integration provides a way to use SQLite databases within your Aspire applications, and access them via the [`Microsoft.Data.Sqlite`](https://www.nuget.org/packages/Microsoft.Data.Sqlite) client. - -## Hosting integration - -The SQLite hosting integration models a SQLite database as the `SQLiteResource` type and will create the database file in the specified location. To access these types and APIs, install the [📦 CommunityToolkit.Aspire.Hosting.SQLite](https://nuget.org/packages/CommunityToolkit.Aspire.Hosting.SQLite) NuGet package in the AppHost project. - - - -### Add SQLite resource - -In the AppHost project, register and consume the SQLite integration using the `AddSQLite` extension method to add the SQLite database to the application builder. - -```csharp title="C# — AppHost.cs" -var builder = DistributedApplication.CreateBuilder(args); - -var sqlite = builder.AddSQLite("my-database"); - -var exampleProject = builder.AddProject() - .WithReference(sqlite); -``` - -When Aspire adds a SQLite database to the AppHost, as shown in the preceding example, it creates a new SQLite database file in the users temp directory. - -Alternatively, if you want to specify a custom location for the SQLite database file, provide the relevant arguments to the `AddSqlite` method. - -```csharp -var sqlite = builder.AddSQLite("my-database", "C:\\Database\\Location", "my-database.db"); -``` - -### Add SQLiteWeb resource - -When adding the SQLite resource, you can also add the SQLiteWeb resource, which provides a web interface to interact with the SQLite database. To do this, use the `WithSqliteWeb` extension method. - -```csharp -var sqlite = builder.AddSQLite("my-database") - .WithSqliteWeb(); -``` - -This code adds a container based on `ghcr.io/coleifer/sqlite-web` to the AppHost, which provides a web interface to interact with the SQLite database it is connected to. Each SQLiteWeb instance is connected to a single SQLite database, meaning that if you add multiple SQLiteWeb instances, there will be multiple SQLiteWeb containers. - -### Adding SQLite extensions - -SQLite supports extensions that can be added to the SQLite database. Extensions can either be provided via a NuGet package, or via a location on disk. Use either the `WithNuGetExtension` or `WithLocalExtension` extension methods to add extensions to the SQLite database. - - - -## Client integration - -To get started with the Aspire SQLite client integration, install the [📦 CommunityToolkit.Aspire.Microsoft.Data.Sqlite](https://www.nuget.org/packages/CommunityToolkit.Aspire.Microsoft.Data.Sqlite) NuGet package in the client-consuming project. The SQLite client integration registers a [`SqliteConnection`](https://learn.microsoft.com/dotnet/api/microsoft.data.sqlite.sqliteconnection) instance that you can use to interact with SQLite. - - - -### Add SQLite client - -In the `Program.cs` file of your client-consuming project, call the `AddSqliteConnection` extension method to register a `SqliteConnection` for use via the dependency injection container. The method takes a connection name parameter. - -```csharp -builder.AddSqliteConnection(name: "sqlite"); -``` - - - -After adding `SqliteConnection` to the builder, you can get the `SqliteConnection` instance using dependency injection. For example, to retrieve your connection object from an example service define it as a constructor parameter: - -```csharp -public class ExampleService(SqliteConnection connection) -{ - // Use connection... -} -``` - -### Add keyed SQLite client - -There might be situations where you want to register multiple `SqliteConnection` instances with different connection names. To register keyed SQLite clients, call the `AddKeyedSqliteConnection` method: - -```csharp -builder.AddKeyedSqliteConnection(name: "chat"); -builder.AddKeyedSqliteConnection(name: "queue"); -``` - -Then you can retrieve the `SqliteConnection` instances using dependency injection: - -```csharp -public class ExampleService( - [FromKeyedServices("chat")] SqliteConnection chatConnection, - [FromKeyedServices("queue")] SqliteConnection queueConnection) -{ - // Use connections... -} -``` - -### Configuration - -The SQLite client integration provides multiple configuration approaches and options to meet the requirements and conventions of your project. - -#### Use a connection string - -When using a connection string from the `ConnectionStrings` configuration section, you can provide the name of the connection string when calling the `AddSqliteConnection` method: - -```csharp -builder.AddSqliteConnection("sqlite"); -``` - -Then the connection string will be retrieved from the `ConnectionStrings` configuration section: - -```json -{ - "ConnectionStrings": { - "sqlite": "Data Source=C:\\Database\\Location\\my-database.db" - } -} -``` - -#### Use configuration providers - -The SQLite client integration supports configuration. It loads the settings from configuration using the `Aspire:Sqlite:Client` key. Example `appsettings.json` that configures some of the options: - -```json -{ - "Aspire": { - "Sqlite": { - "Client": { - "ConnectionString": "Data Source=C:\\Database\\Location\\my-database.db", - "DisableHealthCheck": true - } - } - } -} -``` diff --git a/src/frontend/src/content/docs/integrations/databases/sqlite/sqlite-client.mdx b/src/frontend/src/content/docs/integrations/databases/sqlite/sqlite-client.mdx new file mode 100644 index 00000000..f7091e59 --- /dev/null +++ b/src/frontend/src/content/docs/integrations/databases/sqlite/sqlite-client.mdx @@ -0,0 +1,170 @@ +--- +title: SQLite Client integration reference +description: Learn how to use the Aspire SQLite Client integration to query SQLite databases from your Aspire projects. +next: false +--- + +import { Aside } from '@astrojs/starlight/components'; +import { Badge } from '@astrojs/starlight/components'; +import InstallPackage from '@components/InstallPackage.astro'; +import InstallDotNetPackage from '@components/InstallDotNetPackage.astro'; +import { Image } from 'astro:assets'; +import sqliteIcon from '@assets/icons/sqlite-icon.png'; + + + +SQLite logo + +To get started with the Aspire SQLite integrations, follow the [Get started with SQLite integrations](../sqlite-get-started/) guide. + +This article includes full details about the Aspire SQLite Client integration, which allows you to connect to and interact with SQLite databases from your Aspire consuming projects. + +## Installation + +To get started with the Aspire SQLite client integration, install the [📦 CommunityToolkit.Aspire.Microsoft.Data.Sqlite](https://www.nuget.org/packages/CommunityToolkit.Aspire.Microsoft.Data.Sqlite) NuGet package in the client-consuming project, that is, the project for the application that uses the SQLite client. The SQLite client integration registers a [`SqliteConnection`](https://learn.microsoft.com/dotnet/api/microsoft.data.sqlite.sqliteconnection) instance that you can use to interact with SQLite. + + + +## Add SQLite client + +In the `Program.cs` file of your client-consuming project, call the `AddSqliteConnection` extension method to register a `SqliteConnection` for use via the dependency injection container. The method takes a connection name parameter. + +```csharp title="C# — Program.cs" +builder.AddSqliteConnection(connectionName: "sqlite"); +``` + + + +After adding `SqliteConnection` to the builder, you can get the `SqliteConnection` instance using dependency injection. For example, to retrieve your connection object from an example service define it as a constructor parameter: + +```csharp title="C# — ExampleService.cs" +public class ExampleService(SqliteConnection connection) +{ + // Use connection... +} +``` + +For more information on dependency injection, see [.NET dependency injection](https://learn.microsoft.com/dotnet/core/extensions/dependency-injection). + +## Add keyed SQLite client + +There might be situations where you want to register multiple `SqliteConnection` instances with different connection names. To register keyed SQLite clients, call the `AddKeyedSqliteConnection` method: + +```csharp title="C# — Program.cs" +builder.AddKeyedSqliteConnection(name: "chat"); +builder.AddKeyedSqliteConnection(name: "queue"); +``` + + + +Then you can retrieve the `SqliteConnection` instances using dependency injection: + +```csharp title="C# — ExampleService.cs" +public class ExampleService( + [FromKeyedServices("chat")] SqliteConnection chatConnection, + [FromKeyedServices("queue")] SqliteConnection queueConnection) +{ + // Use connections... +} +``` + +For more information on keyed services, see [.NET dependency injection: Keyed services](https://learn.microsoft.com/dotnet/core/extensions/dependency-injection#keyed-services). + +## Properties of the SQLite resources + +When you use the `WithReference` method to pass a SQLite database resource from the AppHost project to a consuming client project, Aspire exposes the data source as an environment variable with a standardized naming convention: + +| Property Name | Description | Environment Variable Format | +|---------------|-------------|----------------------------| +| `DataSource` | The data source path containing the database file path. | `C:\{Path}\{Databasefile}.db` | + + + +## Configuration + +The SQLite client integration provides multiple options to configure the connection based on the requirements and conventions of your project. + +### Use a connection string + +When using a connection string from the `ConnectionStrings` configuration section, you can provide the name of the connection string when calling the `AddSqliteConnection` method: + +```csharp title="C# — Program.cs" +builder.AddSqliteConnection("sqlite"); +``` + +Then the connection string will be retrieved from the `ConnectionStrings` configuration section: + +```json title="JSON — appsettings.json" +{ + "ConnectionStrings": { + "sqlite": "Data Source=C:\\Database\\Location\\my-database.db" + } +} +``` + +For more information on how to format this connection string, see [Microsoft.Data.Sqlite connection strings](https://learn.microsoft.com/dotnet/standard/data/sqlite/connection-strings). + +### Use configuration providers + +The SQLite client integration supports `Microsoft.Extensions.Configuration`. It loads the settings from configuration using the `Aspire:Sqlite:Client` key. Example `appsettings.json` that configures some of the options: + +```json title="JSON — appsettings.json" +{ + "Aspire": { + "Sqlite": { + "Client": { + "ConnectionString": "Data Source=C:\\Database\\Location\\my-database.db", + "DisableHealthCheck": true + } + } + } +} +``` + +### Use inline delegates + +You can also pass the `Action` delegate to set up some or all the options inline: + +```csharp title="C# — Program.cs" +builder.AddSqliteConnection( + "sqlite", + static settings => settings.DisableHealthCheck = true); +``` + +## Client integration health checks + +By default, Aspire integrations enable [health checks](/fundamentals/health-checks/) for all services. For more information, see [Aspire integrations overview](/integrations/overview/). + +The Aspire SQLite integration: + +- Adds the health check when `SqliteConnectionSettings.DisableHealthCheck` is `false`, which attempts to open a connection to the SQLite database. +- Integrates with the `/health` HTTP endpoint, which specifies all registered health checks must pass for app to be considered ready to accept traffic. + +## Observability and telemetry + +Aspire integrations automatically set up Logging, Tracing, and Metrics configurations, which are sometimes known as *the pillars of observability*. Depending on the backing service, some integrations may only support some of these features. For example, some integrations support logging and tracing, but not metrics. Telemetry features can also be disabled using the techniques presented in the [Configuration](#configuration) section. + +### Logging + +The Aspire SQLite integration uses standard .NET logging mechanisms for database operations. + +### Tracing + +The Aspire SQLite integration will emit tracing activities for database operations using OpenTelemetry when configured. + +### Metrics + +The Aspire SQLite integration currently has limited metrics support compared to other database integrations due to the nature of SQLite as an embedded database engine. diff --git a/src/frontend/src/content/docs/integrations/databases/sqlite/sqlite-get-started.mdx b/src/frontend/src/content/docs/integrations/databases/sqlite/sqlite-get-started.mdx new file mode 100644 index 00000000..3d1ffd66 --- /dev/null +++ b/src/frontend/src/content/docs/integrations/databases/sqlite/sqlite-get-started.mdx @@ -0,0 +1,251 @@ +--- +title: Get started with the SQLite integrations +description: Learn how to set up the Aspire SQLite Hosting and Client integrations simply. +prev: false +--- + +import { Image } from 'astro:assets'; +import { Kbd } from 'starlight-kbd/components'; +import { Badge } from '@astrojs/starlight/components'; +import InstallPackage from '@components/InstallPackage.astro'; +import InstallDotNetPackage from '@components/InstallDotNetPackage.astro'; +import { Aside, CardGrid, LinkCard, Code, Steps, Tabs, TabItem } from '@astrojs/starlight/components'; +import PivotSelector from '@components/PivotSelector.astro'; +import Pivot from '@components/Pivot.astro'; +import ThemeImage from '@components/ThemeImage.astro'; +import sqliteIcon from '@assets/icons/sqlite-icon.png'; + + + +SQLite logo + +[SQLite](https://www.sqlite.org/index.html) is a lightweight, serverless, self-contained SQL database engine that is widely used for local data storage in applications. The Aspire SQLite integration provides a way to use SQLite databases within your Aspire applications, and access them via the [`Microsoft.Data.Sqlite`](https://www.nuget.org/packages/Microsoft.Data.Sqlite) client. + +In this introduction, you'll see how to install and use the Aspire SQLite integrations in a simple configuration. If you already have this knowledge, see [SQLite Hosting integration](../sqlite-host/) for full reference details. + + + +## Set up hosting integration + +To begin, install the Aspire SQLite Hosting integration in your Aspire AppHost project. This integration allows you to create and manage SQLite database instances from your Aspire hosting projects: + + + +Next, in the AppHost project, create an instance of a SQLite database resource, then pass the database to the consuming client projects: + + + + + +```csharp title="C# — AppHost.cs" +var builder = DistributedApplication.CreateBuilder(args); + +var sqlite = builder.AddSqlite("sqlite"); + +var exampleProject = builder.AddProject("apiservice") + .WaitFor(sqlite) + .WithReference(sqlite); +``` + + + + + +```csharp title="C# — AppHost.cs" +var builder = DistributedApplication.CreateBuilder(args); + +var sqlite = builder.AddSqlite("sqlite"); + +var exampleProject = builder.AddUvicornApp("api", "./api", "main.app") + .WithExternalHttpEndpoints() + .WaitFor(sqlite) + .WithReference(sqlite); +``` + + + + + +```csharp title="C# — AppHost.cs" +var builder = DistributedApplication.CreateBuilder(args); + +var sqlite = builder.AddSqlite("sqlite"); + +var api = builder.AddNodeApp("api", "./api", scriptPath: "index.js") + .WithExternalHttpEndpoints() + .WaitFor(sqlite) + .WithReference(sqlite); +``` + + + + + +## Use the integration in client projects + +Now that the hosting integration is ready, the next step is to install and configure the client integration in any projects that need to use it. + +### Set up client projects + + + +In each of these consuming client projects, install the Aspire SQLite client integration: + + + +In the `Program.cs` file of your client-consuming project, call the `AddSqliteConnection` extension method on any `IHostApplicationBuilder` to register a `SqliteConnection` for use via the dependency injection container. The method takes a connection name parameter. + +```csharp title="C# — Program.cs" +builder.AddSqliteConnection("sqlite"); +``` + + + + + + + +To interact with SQLite databases in your Python consuming projects, you can use the built-in `sqlite3` module (included in Python's standard library). No additional installation is required: + +```python title="Python - Import sqlite3" +import sqlite3 +import os +``` + + + + + +To interact with SQLite databases in your JavaScript consuming projects, you need to include a SQLite client library. A popular option is `sqlite3`. You can install this library using npm: + +```bash +npm install sqlite3 +``` + +Ensure that you `import sqlite3` in code files that interact with the database: + +```javascript title="JavaScript - Import sqlite3" +import sqlite3 from 'sqlite3'; +``` + + + +### Use injected SQLite properties + +In the AppHost, when you used the `WithReference` method to pass a SQLite database resource to a consuming client project, Aspire injects the data source configuration property that you can use in the consuming project. + +Aspire exposes the property as an environment variable named `[RESOURCE]_DATASOURCE`. For instance, the data source of a resource called `sqlite` becomes `SQLITE_DATASOURCE`. + + + +Use the `GetValue()` method to obtain this environment variable in consuming projects: + +```csharp title="C# - Obtain configuration properties" +string sqldatasource = builder.Configuration.GetValue("SQLITE_DATASOURCE"); +``` + + + + + +Use the `os.getenv()` method to obtain this environment variable in consuming projects: + +```python title="Python - Obtain configuration properties" +connection_string = os.getenv("SQLITE_DATASOURCE") +``` + + + + + +Use the `process.env` method to obtain this environment variable in consuming projects: + +```javascript title="JavaScript - Obtain configuration properties" +const connectionString = process.env.SQLITE_DATASOURCE; +``` + + + + + +### Use SQLite resources in client code + + + +Now that you've added `SqliteConnection` to the builder in the consuming project, you can use the SQLite resource to get and store data. Get the `SqliteConnection` instance using dependency injection. For example, to retrieve your connection object from an example service define it as a constructor parameter and ensure the `ExampleService` class is registered with the dependency injection container: + +```csharp title="C# — ExampleService.cs" +public class ExampleService(SqliteConnection connection) +{ + // Use connection to query the database... +} +``` + +Having obtained the connection, you can work with the SQLite database as you would in any other C# application. + + + + + +Use the information you have obtained about the SQLite resource to connect to the database. Here is an example of how to connect using `sqlite3`: + +```python title="Python - Connect to SQLite" +connection = sqlite3.connect(connection_string) +cursor = connection.cursor() +``` + +Having obtained the connection, you can work with the SQLite database as you would in any other Python application. + + + + + +Use the information you have obtained about the SQLite resource to connect to the database. Here is an example of how to connect using `sqlite3`: + +```javascript title="JavaScript - Connect to SQLite" +const db = new sqlite3.Database(connectionString); +``` + +Having obtained the connection, you can work with the SQLite database as you would in any other JavaScript application. + + + +## Next steps + +Now, that you have an Aspire app with SQLite integrations up and running, you can use the following reference documents to learn how to configure and interact with the SQLite resources: + + + + + diff --git a/src/frontend/src/content/docs/integrations/databases/sqlite/sqlite-host.mdx b/src/frontend/src/content/docs/integrations/databases/sqlite/sqlite-host.mdx new file mode 100644 index 00000000..81ae7714 --- /dev/null +++ b/src/frontend/src/content/docs/integrations/databases/sqlite/sqlite-host.mdx @@ -0,0 +1,150 @@ +--- +title: SQLite Hosting integration reference +description: Learn how to use the Aspire SQLite Hosting integration to create and manage SQLite database resources in your Aspire projects. +--- + +import { Aside } from '@astrojs/starlight/components'; +import { Badge } from '@astrojs/starlight/components'; +import InstallPackage from '@components/InstallPackage.astro'; +import { Image } from 'astro:assets'; +import sqliteIcon from '@assets/icons/sqlite-icon.png'; + + + +SQLite logo + +To get started with the Aspire SQLite integrations, follow the [Get started with SQLite integrations](../sqlite-get-started/) guide. + +This article includes full details about the Aspire SQLite Hosting integration, which models a SQLite database as the `SQLiteResource` type. To access these types and APIs, you need to install the SQLite Hosting integration in your AppHost project. + +## Installation + +The SQLite hosting integration models a SQLite database as the `SQLiteResource` type and will create the database file in the specified location. To get started with the Aspire SQLite hosting integration, install the [📦 CommunityToolkit.Aspire.Hosting.SQLite](https://nuget.org/packages/CommunityToolkit.Aspire.Hosting.SQLite) NuGet package in your AppHost project: + + + +## Add SQLite resource + +In the AppHost project, register and consume the SQLite integration using the `AddSQLite` extension method to add the SQLite database to the application builder. + +```csharp title="C# — AppHost.cs" +var builder = DistributedApplication.CreateBuilder(args); + +var sqlite = builder.AddSqlite("my-database"); + +var exampleProject = builder.AddProject() + .WithReference(sqlite); +``` + +When Aspire adds a SQLite database to the AppHost, as shown in the preceding example, it creates a new SQLite database file in the users temp directory. + +Alternatively, if you want to specify a custom location for the SQLite database file, provide the relevant arguments to the `AddSqlite` method. + +```csharp title="C# — AppHost.cs" +var builder = DistributedApplication.CreateBuilder(args); + +var sqlite = builder.AddSqlite("my-database", "C:\\Database\\Location", "my-database.db"); + +var exampleProject = builder.AddProject() + .WithReference(sqlite); +``` + +The preceding code creates a SQLite database file at `C:\Database\Location\my-database.db`. The database file is created if it doesn't already exist. + +## Add SQLiteWeb resource + +When adding the SQLite resource, you can also add the SQLiteWeb resource, which provides a web interface to interact with the SQLite database. To do this, use the `WithSqliteWeb` extension method. + +```csharp title="C# — AppHost.cs" +var builder = DistributedApplication.CreateBuilder(args); + +var sqlite = builder.AddSqlite("my-database") + .WithSqliteWeb(); + +var exampleProject = builder.AddProject() + .WithReference(sqlite); +``` + +This code adds a container based on `ghcr.io/coleifer/sqlite-web` to the AppHost, which provides a web interface to interact with the SQLite database it is connected to. Each SQLiteWeb instance is connected to a single SQLite database, meaning that if you add multiple SQLiteWeb instances, there will be multiple SQLiteWeb containers. + +When you run the solution, the Aspire dashboard displays the SQLiteWeb resource with an endpoint. Select the link to the endpoint to view SQLiteWeb in a new browser tab. + +## Adding SQLite extensions + +SQLite supports extensions that can be added to the SQLite database. Extensions can either be provided via a NuGet package, or via a location on disk. Use either the `WithNuGetExtension` or `WithLocalExtension` extension methods to add extensions to the SQLite database. + +```csharp title="C# — AppHost.cs (NuGet extension)" +var builder = DistributedApplication.CreateBuilder(args); + +var sqlite = builder.AddSqlite("my-database") + .WithNuGetExtension("SQLitePCLRaw.lib.e_sqlite3"); + +var exampleProject = builder.AddProject() + .WithReference(sqlite); +``` + +```csharp title="C# — AppHost.cs (Local extension)" +var builder = DistributedApplication.CreateBuilder(args); + +var sqlite = builder.AddSqlite("my-database") + .WithLocalExtension("C:\\Extensions\\my-extension.dll"); + +var exampleProject = builder.AddProject() + .WithReference(sqlite); +``` + + + +## Using with non-.NET applications + +When you use the `WithReference` method to pass a SQLite database resource to a non-.NET application (such as Python or JavaScript), Aspire automatically injects environment variables that describe the connection information. + +For example, if you reference a SQLite database resource named `sqlite`: + +```csharp title="C# — AppHost.cs" +var sqlite = builder.AddSqlite("sqlite"); + +var pythonApp = builder.AddUvicornApp("api", "./api", "main.app") + .WithReference(sqlite); +``` + +The following environment variable is available in the Python application: + +- `ConnectionStrings__sqlite` - The connection string containing the database file path + +You can access this environment variable in your application code: + +```python title="Python example" +import os +import sqlite3 + +connection_string = os.getenv("ConnectionStrings__sqlite") +# Extract the database file path from the connection string +# ConnectionStrings typically look like: "Data Source=/path/to/file.db" +db_path = connection_string.replace("Data Source=", "") + +connection = sqlite3.connect(db_path) +cursor = connection.cursor() +``` + +```javascript title="JavaScript example" +import Database from 'better-sqlite3'; + +const connectionString = process.env.ConnectionStrings__sqlite; +// Extract the database file path from the connection string +const dbPath = connectionString.replace("Data Source=", ""); + +const db = new Database(dbPath); +``` + +For the complete list of properties available, see [Properties of the SQLite resources](../sqlite-client/#properties-of-the-sqlite-resources). diff --git a/src/frontend/src/data/integration-docs.json b/src/frontend/src/data/integration-docs.json index 6d8473c8..85554d9c 100644 --- a/src/frontend/src/data/integration-docs.json +++ b/src/frontend/src/data/integration-docs.json @@ -449,7 +449,7 @@ }, { "match": "CommunityToolkit.Aspire.Hosting.Sqlite", - "href": "/integrations/databases/sqlite/" + "href": "/integrations/databases/sqlite/sqlite-host/" }, { "match": "CommunityToolkit.Aspire.Hosting.SqlServer.Extensions", @@ -469,11 +469,11 @@ }, { "match": "CommunityToolkit.Aspire.Microsoft.Data.Sqlite", - "href": "/integrations/databases/sqlite/" + "href": "/integrations/databases/sqlite/sqlite-client/" }, { "match": "CommunityToolkit.Aspire.Microsoft.EntityFrameworkCore.Sqlite", - "href": "/integrations/databases/sqlite/" + "href": "/integrations/databases/sqlite/sqlite-host/" }, { "match": "CommunityToolkit.Aspire.OllamaSharp",