https://github.com/calculationcollective/sqlcalculator
https://github.com/calculationcollective/sqlcalculator
calculator sql sqlite
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/calculationcollective/sqlcalculator
- Owner: CalculationCollective
- License: other
- Created: 2023-02-10T20:14:16.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-02-10T21:13:48.000Z (over 2 years ago)
- Last Synced: 2025-01-08T16:08:00.637Z (6 months ago)
- Topics: calculator, sql, sqlite
- Language: SQL
- Homepage:
- Size: 2.93 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# SQLCalculator
- [SQLCalculator](#aqlcalculator)
- [Introduction](#introduction)
- [Installing SQLite](#installing-sqlite)
- [Execute the calculator](#execute-the-calculator)
- [Use the calculator](#use-the-calculator)## Introduction
This SQL calculator was created for the SQLite dialect and works by utilising triggers.## Installing SQLite
You can download precompiled versions of sqlite from the [official website](https://www.sqlite.org/download.html).## Execute the calculator
To set-up the calculator you will need to run the sql script (`SQLCalculator.sql`) on an `.sqlite` file.
```bash
sqlite3 database_file.sqlite # open your sqlite database
.read SQLCalculator.sql # inside the sqlite terminal you can run the sql script
```## Use the calculator
The calculator is used via the INSERT command. First open your `.sqlite` file in sqlite. Then enter the INSERT command. After that you can user a SELECT statement to view the result of the calculation.
```bash
sqlite3 database_file.sqlite # open your sqlite database.
INSERT INTO Calculations(Num1, CalculationType, Num2) VALUES (1, '+', 1); # insert your calculation
SELECT Result FROM Calculations WHERE Id = (SELECT MAX(Id) FROM Calculations); # view the result of your calculation (result will be 2.0 for this calculation)
```