DatabaseCS 1.0.4

.NET Framework

Requires NuGet 1.0 or higher.

Install-Package DatabaseCS -Version 1.0.4
dotnet add package DatabaseCS --version 1.0.4
<PackageReference Include="DatabaseCS" Version="1.0.4" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DatabaseCS --version 1.0.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: DatabaseCS, 1.0.4"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install DatabaseCS as a Cake Addin
#addin nuget:?package=DatabaseCS&version=1.0.4

// Install DatabaseCS as a Cake Tool
#tool nuget:?package=DatabaseCS&version=1.0.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.


Small note

In the examples right below you'll see that i use a lot of strings variables starting with $"my string" it is because it allow me to easily concat variables into my string, it also automatically convert the type of the variable into a string.

Also please note that english is not my main language, i'm a computer science student and as i use this library a lot i've choosed to share it with you :3


This packages is using

How to use it

After downloading the project you just have to include it in your usings using → using DatabaseCS.

After that you'll have to establish the connection with the database using the Database.Connect() (do not forget to surround it with a try-catch because an error will be thrown if the connection failed) The connection method has an overloard containing a password in case if your database needs a password. Argument → ( (Server, Database, Username, (Password) )

Example without password
//Establish a connection without a password
Database.Connect("localhost", "MyDb", "root");
Exeample with a password
//Establish a connection with a password
Database.Connect("localhost", "MyDb", "root", "password");


Since the 1.0.2 the usage of this library is way easier, and also faster. <sub>*Before attempting to execute ANY request you HAVE to establish a connection with the server.</sub>

  • Select The Select method return a list of dictionnary containing your data, the keys to the date is the column name. It might look a bit scary but using a var type variable makes it easier.

There are two ways of executing a select request.

Exemple standard
var Data = Database.Select($"SELECT prenom, nom, age FROM tbl_users WHERE id={this.Id}");

<sub>(The argument of the method is a String, you can also put a string variable containing your request in here)</sub>

Example using the extension method
var Data = strRequest.Select();


var Data = "SELECT * FROM tbl_users".Select();

  • How to use the fetched datas Once the select done you can check all of the datas using a foreach.
If you know that your request only return one record you can do something like this
var Data = strRequete.Select();

<sub>This will display in the console the firstname of the first fetched record.</sub>

  • This example will display the names of all of the user in my db, user by user
var Data = "SELECT * FROM tbl_users".Select();
foreach(Dictionnary<string, string> row in Data){

If this example looks a bit too complicated you can also do it like this :

var Data = "SELECT * FROM tbl_users".Select();
foreach(var row in Data){

<sub> Be careful ! doing it this way might frighten your teachers..</sub>

  • Insert <sub>The argument to pass in parameter is your sql request.</sub>
Database.Write($"INSERT INTO tbl_users(prenom, nom, age) VALUES(\"{firstname}\",\"{name}\",{age}");


$"INSERT INTO tbl_users(prenom, nom, age) VALUES(\"{firstname}\",\"{name}\",{age}".Write();
  • Update
Database.Write($"UPDATE tbl_users SET age={age} WHERE nom = \"{name}\"");


$"UPDATE tbl_users SET age={age} WHERE nom = \"{name}\"".Write();
Product Versions
.NET Framework net
Compatible target framework(s)
Additional computed target framework(s)
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.

Version Downloads Last updated
1.0.4 207 9/16/2021
1.0.3 158 9/16/2021
1.0.2 215 9/12/2021
1.0.1 219 9/12/2021
1.0.0 211 9/12/2021