All Projects → Zaid-Ajaj → ThrowawayDb

Zaid-Ajaj / ThrowawayDb

Licence: MIT license
Dead simple integration tests with SQL Server or Postgres throwaway databases that are created on the fly, used briefly then disposed of automagically.

Programming Languages

C#
18002 projects
powershell
5483 projects
shell
77523 projects

Projects that are alternatives of or similar to ThrowawayDb

Obevo
Obevo is a database deployment tool that handles enterprise scale schemas and complexity
Stars: ✭ 192 (+40.15%)
Mutual labels:  sql-server
Sqlfiddle3
New version based on vert.x and docker
Stars: ✭ 242 (+76.64%)
Mutual labels:  sql-server
community-presentations
Presentation Repository for SQL Server / PowerShell Presentations within the Community
Stars: ✭ 38 (-72.26%)
Mutual labels:  sql-server
Tsql Parser
Library Written in C# For Parsing SQL Server T-SQL Scripts in .Net
Stars: ✭ 203 (+48.18%)
Mutual labels:  sql-server
Projectnami
WordPress powered by Microsoft SQL Server
Stars: ✭ 238 (+73.72%)
Mutual labels:  sql-server
bizbook-server
The repository of bizbook server web api project
Stars: ✭ 45 (-67.15%)
Mutual labels:  sql-server
Nut
Advanced, Powerful and easy to use ORM for Qt
Stars: ✭ 181 (+32.12%)
Mutual labels:  sql-server
database
Joomla Framework Database Package
Stars: ✭ 25 (-81.75%)
Mutual labels:  sql-server
Tds fdw
A PostgreSQL foreign data wrapper to connect to TDS databases (Sybase and Microsoft SQL Server)
Stars: ✭ 238 (+73.72%)
Mutual labels:  sql-server
dbfx
This is a free, cross platform, open source database management tool based on JavaFX and vertx SQL client.
Stars: ✭ 63 (-54.01%)
Mutual labels:  sql-server
Ssis Dashboard
HTML5 SQL Server Integration Services Dashboard
Stars: ✭ 206 (+50.36%)
Mutual labels:  sql-server
Fluentmigrator
Fluent migrations framework for .NET
Stars: ✭ 2,636 (+1824.09%)
Mutual labels:  sql-server
DacFx
SQL Server database schema validation, deployment, and upgrade runtime. Enables declarative database development and database portability across SQL Server versions and environments.
Stars: ✭ 152 (+10.95%)
Mutual labels:  sql-server
Sql Server First Responder Kit
sp_Blitz, sp_BlitzCache, sp_BlitzFirst, sp_BlitzIndex, and other SQL Server scripts for health checks and performance tuning.
Stars: ✭ 2,482 (+1711.68%)
Mutual labels:  sql-server
MinimalApi
ASP.NET Core 7.0 - Minimal API Example - Todo API implementation using ASP.NET Core Minimal API, Entity Framework Core, Token authentication, Versioning, Unit Testing, Integration Testing and Open API.
Stars: ✭ 156 (+13.87%)
Mutual labels:  sql-server
Denunciado
This project born from the need from people to have a way of communication between municipalities and communities. Some municipalities, have their platforms, but they are complex to validate the veracity of complaints. Denounced, it was born with the purpose of offering a free platform to these municipalities. Denounced consists of three main modules developed with Microsoft technologies, using the .Net Framework and Xamarin for its development: 1. Back End Web Project: Module of administration of the complaints, by the employees of the town councils. In this tool, the employees of the city council receive, validate, report and close the complaints, after being served. 2. Web Portal Client: It consists of a web project, so that the community make their complaints, in the same, the users of the service create a profile, must specify when making their complaint, evidence to support this. Through the portal, they can see the complaints of other community members, follow it, give their opinion or provide possible solutions or more evidence. 3. Mobile Project: It has the same functionalities as the web portal, with the addition, that the automatic location can be sent, from the cell phone.
Stars: ✭ 183 (+33.58%)
Mutual labels:  sql-server
Packer
Packer helpers and templates for Docker, IIS, SQL Server and Visual Studio on Windows and Ubuntu
Stars: ✭ 242 (+76.64%)
Mutual labels:  sql-server
MsCoreOne
MsCoreOne is a simple Ecommerce with using many technologies such as .NET 5, Entity Framework Core 5, React 16.13 with modern Clean Architecture, Domain-Driven Design, CQRS, SOLID, Identity Server 4, Blazor. It will focus on resolving the problems always see in the process to develop projects.
Stars: ✭ 77 (-43.8%)
Mutual labels:  sql-server
e-commerce-backend
Shopping site backend which used Asp.Net Web API, JWT, Cache, Log, SqlServer, Entity Framework Core and N-Layer Architecture implementation.
Stars: ✭ 16 (-88.32%)
Mutual labels:  sql-server
AlwaysEncryptedSample
Sample ASP.NET MVC Application for demonstrating Microsoft SQL Server Always Encrypted Functionality
Stars: ✭ 14 (-89.78%)
Mutual labels:  sql-server

ThrowawayDb

Easily create a disposable database that integration tests dead simple for Sql server using throwaway databases.

Available Packages

Package Supports Version
ThrowawayDb SQL Server Nuget
ThrowawayDb.Postgres Postgres Nuget
ThrowawayDb.MySQL MySQL Nuget

Using SQL Server

Install ThrowawayDb from Nuget

dotnet add package ThrowawayDb

Use from your code

public static void Main(string[] args)
{
    using (var database = ThrowawayDatabase.FromLocalInstance("localhost\\SQLEXPRESS"))
    {
        Console.WriteLine($"Created database {database.Name}");

        // - Apply database migrations here if necessary
        // - Seed the database with data
        // - Execute your code against this database
        using var connection = new SqlConnection(database.ConnectionString);
        connection.Open();
        using var cmd = new SqlCommand("SELECT 1", connection);
        var result = Convert.ToInt32(cmd.ExecuteScalar());
        Console.WriteLine(result);
    }
}

In the snippet above, a dummy database with a random name is created using the current local instance of SQL Express on my machine. Moreover, the object database is an IDisposable and will drop the database at the end of the using clause when it's Dispose() is executed. It is that simple!

You can create the throwaway database in multiple ways:

// from Sql Express server locally with Integrated security
ThrowawayDatabase.FromLocalInstance("localhost\\SQLEXPRESS");

// Uses the default instance locally where Data Source = .
ThrowawayDatabase.FromDefaultLocalInstance();

// Using SQL Authentication with user credentials and an arbibrary host
ThrowawayDatabase.Create(username: "Zaid", password: "strongPassword", host: "192.168.1.100");

// Using a connection string where Initial Catalog is master
ThrowawayDatabase.Create(connectionString: "Data Source=localhost\\SQLEXPRESS;Initial Catalog=master;Integrated Security=True;");

// Specify a custom database prefix, otherwise it just uses ThrowawayDb
ThrowawayDatabase.FromLocalInstance("localhost\\SQLEXPRESS", "dbprefix_");

SQL server snapshot

You can create a snapshot of the database and restore it at a later point:

using var database = ThrowawayDatabase.FromLocalInstance("localhost\\SQLEXPRESS");

// execute necessary actions before initialising a snapshot
database.CreateSnapshot();

// execute some other actions which modify the database
database.RestoreSnapshot();

A snapshot can also be created as a snapshot scope. This way you ensure that the RestoreSnapshot method is always called.

using var database = ThrowawayDatabase.FromLocalInstance("localhost\\SQLEXPRESS");

using(var scope = database.CreateSnapshotScope())
{
    // execute actions that modifies the database, and that should only last inside this scope.
}

Using PostgreSQL server

Install ThrowawayDb.Postgres from Nuget

dotnet add package ThrowawayDb.Postgres

use from your code:

static void Main(string[] args)
{
    using (var database = ThrowawayDatabase.Create(username: "postgres", password: "postgres", host: "localhost"))
    {
        using var connection = new NpgsqlConnection(database.ConnectionString);
        connection.Open();
        using var cmd = new NpgsqlCommand("SELECT 1", connection);
        var result = Convert.ToInt32(cmd.ExecuteScalar());
        Console.WriteLine(result);
    }
}

Using MySQL server

You can create the throwaway database in multiple ways:

// Using SQL Authentication with user credentials and an arbibrary host
ThrowawayDatabase.Create(userName: "Zaid", password: "strongPassword", server: "localhost");

// Using a connection string where Initial Catalog is master
ThrowawayDatabase.Create(connectionString: "server=localhost;user id=Zaid;password=strongPassword;");

// Specify a custom database prefix, otherwise it just uses ThrowawayDb
ThrowawayDatabase.Create(userName: "Zaid", password: "strongPassword", server: "localhost", "dbprefix_");

// Specify all options
ThrowawayDatabase.Create("server=localhost;user id=Zaid;password=strongPassword;", new ThrowawayDatabaseOptions
{
    DatabaseNamePrefix = "dbprefix_",
    Collation = "ujis_japanese_ci"
});

MySQL snapshot

You can create a snapshot of the database and restore it at a later point:

using var database = ThrowawayDatabase.Create("Zaid", "strongPassword", "localhost");

// execute necessary actions before initialising a snapshot
database.CreateSnapshot();

// execute some other actions which modify the database
database.RestoreSnapshot();

Running build targets for development

./build.sh --target {TargetName}

or

build --target {TargetName}

Where {TargetName} is the name of a target in build/buid.cs

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].