Giter VIP home page Giter VIP logo

amazon-qldb-driver-dotnet's Introduction

Amazon QLDB .NET Driver

This is the .NET driver for Amazon Quantum Ledger Database (QLDB), which allows .NET developers to write software that makes use of AmazonQLDB.

This is a preview release of the Amazon QLDB Driver for .NET, and we do not recommend that it be used for production purposes.

nuget License

Requirements

Basic Configuration

See Accessing Amazon QLDB for information on connecting to AWS.

.NET

The driver targets .NET Standard 2.0. Please see the link below for more information on compatibility:

Getting Started

To use the driver, it can be installed using NuGet package manager. The driver package is named:

Amazon.QLDB.Driver

Then, using the driver's namespace, you can now use the driver in your application:

using System;

namespace Hello
{
    using Amazon.QLDB.Driver;
    using Amazon.QLDB;
    using Amazon.QLDB.Model;    
    using Amazon.QLDBSession;
    using Amazon.QLDBSession.Model;
    using Amazon.Runtime;
    using System.Threading;
    using System.Text;

    class Program
    {
        static void Main(string[] args)
        {
            string ledgerName= "my-ledger";

            Console.WriteLine($"Create the ledger '{ledgerName}'");
            AmazonQLDBClient qldbClient = new AmazonQLDBClient();            
            CreateLedgerRequest createLedgerRequest = new CreateLedgerRequest
            {
                Name = ledgerName,
                PermissionsMode = PermissionsMode.ALLOW_ALL
            };
            qldbClient.CreateLedgerAsync(createLedgerRequest).GetAwaiter().GetResult();

            Console.WriteLine($"Waiting for ledger to be active");
            DescribeLedgerRequest describeLedgerRequest = new DescribeLedgerRequest {
                Name = ledgerName
            };
            while (true)
            {
                DescribeLedgerResponse describeLedgerResponse = qldbClient.DescribeLedgerAsync(describeLedgerRequest).GetAwaiter().GetResult();

                if (describeLedgerResponse.State.Equals(LedgerState.ACTIVE.Value))
                {
                    Console.WriteLine($"'{ ledgerName }' ledger created sucessfully.");
                    break;
                }
                Console.WriteLine($"Creating the '{ ledgerName }' ledger...");
                Thread.Sleep(1000);
            }

            AmazonQLDBSessionConfig amazonQldbSessionConfig = new AmazonQLDBSessionConfig();
            Console.WriteLine($"Create the QLDB Driver");
            IQldbDriver driver = PooledQldbDriver.Builder()
                .WithQLDBSessionConfig(amazonQldbSessionConfig)
                .WithLedger(ledgerName)
                .Build();

            string tableName = "MyTable1";
            using (IQldbSession qldbSession = driver.GetSession())
            {
                // qldbSession.Execute will start a transaction and commit it.
                IResult result = qldbSession.Execute($"CREATE TABLE {tableName}");
                Console.WriteLine($"Table '{tableName}' created");
            }
        }
    }
}

See Also

  1. Using the Amazon QLDB Driver for .NET โ€” The best way to get familiar with the Amazon QLDB Driver for .NET is to read Getting Started with the Amazon QLDB Driver in the Amazon QLDB Developer Guide.
  2. QLDB .NET Driver accepts and returns Amazon ION Documents. Amazon Ion is a richly-typed, self-describing, hierarchical data serialization format offering interchangeable binary and text representations. For more information read the ION docs.
  3. Amazon ION Cookbook: This cookbook provides code samples for some simple Amazon Ion use cases.
  4. Amazon QLDB supports the PartiQL query language. PartiQL provides SQL-compatible query access across multiple data stores containing structured data, semistructured data, and nested data. For more information read the PartiQL docs.
  5. Refer the section Common Errors while using the Amazon QLDB Drivers which describes runtime errors that can be thrown by the Amazon QLDB Driver when calling the qldb-session APIs.

Development

Setup

Assuming that Visual Studio is being used, open the solution file (Amazon.QLDB.Driver.sln).

Right click the solution in the Solution Explorer and press "Restore NuGet Packages" if it does not do so automatically.

Running Tests

You can run the unit tests by right clicking the Amazon.QLDB.Driver.Tests project, that is a part of the solution file, and pressing "Run Tests".

Alternatively you can run the unit tests on the command line with the following:

dotnet test

Documentation

DocFx is used for documentation. Download Docfx as docfx.zip, unzip and extract it to a local folder, and add it to PATH.

You can generate the docstring HTML locally by running the following in the root directory of this repository:

docfx docs/docfx.json --serve

Release Notes

Release 0.1.0-beta

  • Initial preview release of the Amazon QLDB Driver for .NET.

License

This library is licensed under the Apache 2.0 License.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.