Alpha.Google.Cloud.Spanner.DataProvider 1.0.0-alpha.20260123102444

This is a prerelease version of Alpha.Google.Cloud.Spanner.DataProvider.
dotnet add package Alpha.Google.Cloud.Spanner.DataProvider --version 1.0.0-alpha.20260123102444
                    
NuGet\Install-Package Alpha.Google.Cloud.Spanner.DataProvider -Version 1.0.0-alpha.20260123102444
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Alpha.Google.Cloud.Spanner.DataProvider" Version="1.0.0-alpha.20260123102444" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Alpha.Google.Cloud.Spanner.DataProvider" Version="1.0.0-alpha.20260123102444" />
                    
Directory.Packages.props
<PackageReference Include="Alpha.Google.Cloud.Spanner.DataProvider" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Alpha.Google.Cloud.Spanner.DataProvider --version 1.0.0-alpha.20260123102444
                    
#r "nuget: Alpha.Google.Cloud.Spanner.DataProvider, 1.0.0-alpha.20260123102444"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Alpha.Google.Cloud.Spanner.DataProvider@1.0.0-alpha.20260123102444
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Alpha.Google.Cloud.Spanner.DataProvider&version=1.0.0-alpha.20260123102444&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Alpha.Google.Cloud.Spanner.DataProvider&version=1.0.0-alpha.20260123102444&prerelease
                    
Install as a Cake Tool

Spanner ADO.NET Data Provider

ALPHA: This library is still in development. It is not yet ready for production use.

ADO.NET Data Provider for Spanner. This library implements the standard ADO.NET interfaces and classes and exposes an API that is similar to ADO.NET data providers for other relational database systems.

Supported Platforms

This driver uses a native library for communication with Spanner. This library supports the following operating systems and architectures:

  • linux-x64
  • linux-arm64
  • osx-arm64
  • win-x64

Usage

Create a connection string using a SpannerConnectionStringBuilder:

var builder = new SpannerConnectionStringBuilder
{
    Project = "my-project",
    Instance = "my-instance",
    Database = "my-database",
    DefaultIsolationLevel = IsolationLevel.ReadCommitted,
};
await using var connection = new SpannerConnection(builder.ConnectionString);
await connection.OpenAsync();
await using var command = connection.CreateCommand();
command.CommandText = "SELECT 'Hello World' as Message";
await using var reader = await command.ExecuteReaderAsync();
while (await reader.ReadAsync())
{
    Console.WriteLine($"Greeting from Spanner: {reader.GetString(0)}");
}

Emulator

The driver can also connect to the Spanner Emulator. The easiest way to do this is to set the AutoConfigEmulator property to true. This instructs the driver to connect to the Emulator on localhost:9010 and to automatically create the Spanner instance and database in the connection string if these do not already exist.

var builder = new SpannerConnectionStringBuilder
{
    Project = "my-project",
    Instance = "my-instance",
    Database = "my-database",
    DefaultIsolationLevel = IsolationLevel.ReadCommitted,
    // Setting AutoConfigEmulator=true instructs the driver to connect to the Spanner emulator on 'localhost:9010',
    // and to create the instance and database on the emulator if these do not already exist.
    AutoConfigEmulator = true,
};
await using var connection = new SpannerConnection(builder.ConnectionString);
await connection.OpenAsync();
await using var command = connection.CreateCommand();
command.CommandText = "SELECT 'Hello World' as Message";
await using var reader = await command.ExecuteReaderAsync();
while (await reader.ReadAsync())
{
    Console.WriteLine($"Greeting from Spanner: {reader.GetString(0)}");
}

Examples

See the spanner-ado-net-samples project for ready-to-run examples for how to use various Spanner features with this driver.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.