Skip to content
Snippets Groups Projects
Commit 61094d33 authored by rs11g21's avatar rs11g21
Browse files

Completed version (Implemented extra error handling)

parent 5054336b
No related branches found
No related tags found
No related merge requests found
#! /usr/bin/bash
output=$(/opt/lampp/bin/mysql -u root -e"USE cryptoTracker; SELECT * FROM crypto;" --skip-column-names 2>&1)
status=$?
# Check the status and handle the error
if [ $status -ne 0 ]; then
echo "MySQL error: $output"
else
echo "MySQL working."
if [ "$(curl -s -o /dev/null -w "%{http_code}" http://www.google.com/)" -eq "200" ]; then
echo "XAMPP's Apache server is connected to the internet."
$(/opt/lampp/bin/mysql -u root -e "create database cryptoTracker; use cryptoTracker")
#To store different types of crypto
$(/opt/lampp/bin/mysql -u root -e "use cryptoTracker; create table crypto (cryptoId int PRIMARY KEY, name varchar(20))")
$(/opt/lampp/bin/mysql -u root -e "use cryptoTracker; insert into crypto values (1,'Bitcoin')")
#To store the crypto price (value)
$(/opt/lampp/bin/mysql -u root -e "use cryptoTracker;
create table cryptoPrice (
id int AUTO_INCREMENT,
cryptoID int,
value float,
collected datetime,
PRIMARY KEY(id),
FOREIGN KEY(cryptoID) REFERENCES crypto(cryptoId)
)")
#To store the 24 Hour Low
$(/opt/lampp/bin/mysql -u root -e "use cryptoTracker;
create table lowPrice (
id int AUTO_INCREMENT,
cryptoID int,
value float,
collected datetime,
PRIMARY KEY(id),
FOREIGN KEY(cryptoID) REFERENCES crypto(cryptoId)
)")
#To store the 24 Hour High
$(/opt/lampp/bin/mysql -u root -e "use cryptoTracker;
create table highPrice (
id int AUTO_INCREMENT,
cryptoID int,
value float,
collected datetime,
PRIMARY KEY(id),
FOREIGN KEY(cryptoID) REFERENCES crypto(cryptoId)
)")
#To store the 24 Hour Open
$(/opt/lampp/bin/mysql -u root -e "use cryptoTracker;
create table openPrice (
id int AUTO_INCREMENT,
cryptoID int,
value float,
collected datetime,
PRIMARY KEY(id),
FOREIGN KEY(cryptoID) REFERENCES crypto(cryptoId)
)")
#To store the Market Cap
$(/opt/lampp/bin/mysql -u root -e "use cryptoTracker;
create table marketCap (
id int AUTO_INCREMENT,
cryptoID int,
value float,
collected datetime,
PRIMARY KEY(id),
FOREIGN KEY(cryptoID) REFERENCES crypto(cryptoId)
)")
#To store the Change In Value
$(/opt/lampp/bin/mysql -u root -e "use cryptoTracker;
create table changeInValue (
id int AUTO_INCREMENT,
cryptoID int,
value float,
collected datetime,
PRIMARY KEY(id),
FOREIGN KEY(cryptoID) REFERENCES crypto(cryptoId)
)")
#To store the Return Percentage
$(/opt/lampp/bin/mysql -u root -e "use cryptoTracker;
create table returnPercentage (
id int AUTO_INCREMENT,
cryptoID int,
value float,
collected datetime,
PRIMARY KEY(id),
FOREIGN KEY(cryptoID) REFERENCES crypto(cryptoId)
)")
#To store the Volatility
$(/opt/lampp/bin/mysql -u root -e "use cryptoTracker;
create table volatility (
id int AUTO_INCREMENT,
cryptoID int,
value float,
collected datetime,
PRIMARY KEY(id),
FOREIGN KEY(cryptoID) REFERENCES crypto(cryptoId)
)")
#To store the Transaction Count
$(/opt/lampp/bin/mysql -u root -e "use cryptoTracker;
create table transactionCount (
id int AUTO_INCREMENT,
cryptoID int,
value float,
collected datetime,
PRIMARY KEY(id),
FOREIGN KEY(cryptoID) REFERENCES crypto(cryptoId)
)")
#To store the Transaction Fee
$(/opt/lampp/bin/mysql -u root -e "use cryptoTracker;
create table transactionFee (
id int AUTO_INCREMENT,
cryptoID int,
value float,
collected datetime,
PRIMARY KEY(id),
FOREIGN KEY(cryptoID) REFERENCES crypto(cryptoId)
)")
else
echo "XAMPP's Apache server is not connected to the internet."
fi
fi
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment