Skip to content
/ tdb Public

Miniature PowerShell Text Relational Database Management System (tdb)

Notifications You must be signed in to change notification settings

voytas75/tdb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Miniature Powershell Text Relational Database Management System (tdb)

tdb

Codacy Badge PowerShell Gallery

Table of Contents

Introduction

The Miniature PowerShell Text Relational Database Management System (tdb) is a lightweight, file-based relational database management system developed using PowerShell. It provides CRUD operations for data storage, retrieval, update, and deletion operations without the need for complex database software.

Installation

  1. Install the Script: Install the PowerShell script file from PowerShell Gallery.

    Install-Script -Name tdb
  2. Run the Script:

    tdb.ps1

    or

    tdb
  3. Show usage guide

    show-tdbUsage

    When you run the script for the first time, it will automatically create a configuration file named .tdb_default.config with default settings. This file will be located in the same directory where the script is. The default settings include paths for the database directory and the log file. You can modify these settings as needed.

    Example of default settings in .tdb_default.config:

    {
     "DBDirectory":  "C:\\Users\\voytas75\\Documents\\tdb\\DB",
     "LogFilePath":  "C:\\Users\\voytas75\\Documents\\tdb\\Logs\\tdb.Log",
    }

Configuration

The script uses a configuration file for settings. These settings can be modified in the .tdb_default.config file.

  • Database Path:

    "DBDirectory": ".\\Database"
  • Log File Path:

    "LogFilePath": ".\\Database\\log.txt"

Ensure that the paths are correctly set according to your environment.

Custom Configuration

You can also create your own configuration file and start the program with the -configFilePath parameter to specify the path to your custom configuration file.

  1. Create a Custom Configuration File:

    Create a JSON file with your desired settings. For example, create a file named my_custom_config.json with the following content:

    {
     "DBDirectory":  "D:\\MyCustomDB\\DB",
     "LogFilePath":  "D:\\MyCustomDB\\Logs\\tdb.Log"
    }
  2. Run the Script with Custom Configuration:

    Use the -configFilePath parameter to specify the path to your custom configuration file when running the script.

    tdb.ps1 -configFilePath "D:\\MyCustomDB\\my_custom_config.json"

    or

    tdb -configFilePath "D:\\MyCustomDB\\my_custom_config.json"

This allows you to have multiple configurations and switch between them as needed.

Usage Guide

Creating a New Table

To create a new table, use the New-tdbTable function. This function requires the table name and the columns you want to include in the table. The table name should only contain alphanumeric characters and underscores.

New-tdbTable -TableName 'Users' -Columns @('Name', 'Email')

Inserting a Record

To insert a new record into a table, use the Insert-tdbRecord function. This function requires the table name and a hashtable representing the record.

Insert-tdbRecord -TableName 'Users' -Record @{Name='John Doe'; Email='john@example.com'}

Reading Records

To read records from a table, use the Get-tdbRecord function. This function requires the table name and a hashtable representing the filter criteria.

get-tdbRecord -TableName "groups1" -ComparisonOperator contains

Updating Records

To update existing records in a table, use the Update-tdbRecords function. This function requires the table name, a hashtable representing the filter criteria, and a hashtable representing the new values.

Update-tdbRecord -TableName 'Users' -Filter @{ID=1} -NewValues @{Email='john.doe@example.com'}

Deleting Records

To delete records from a table, use the Remove-tdbRecords function. This function requires the table name and a hashtable representing the filter criteria.

Remove-tdbRecord -TableName 'Users' -Filter @{ID=1}

Listing Tables

To list all tables in the current database or show info for a specific table, use the Get-tdbTable function.

Get-tdbTable

Support Us on Ko-fi

If you find the Miniature Powershell Text Relational Database Management System (tdb) useful, consider supporting us on Ko-fi. Your support helps us maintain and improve the project. Thank you!

ko-fi

About

Miniature PowerShell Text Relational Database Management System (tdb)

Resources

Stars

Watchers

Forks