From fa553007bce4a393189b10f08216b174b212a24e Mon Sep 17 00:00:00 2001
From: rs11g21 <rs11g21@soton.ac.uk>
Date: Tue, 25 Apr 2023 16:40:34 +0000
Subject: [PATCH] Able to insert live bitcoin price into database

---
 insertDataBitcoinUpdated.sh | 42 +++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
 create mode 100644 insertDataBitcoinUpdated.sh

diff --git a/insertDataBitcoinUpdated.sh b/insertDataBitcoinUpdated.sh
new file mode 100644
index 0000000..a80756d
--- /dev/null
+++ b/insertDataBitcoinUpdated.sh
@@ -0,0 +1,42 @@
+#! /usr/bin/bash
+
+#run by using ./bitCoinTracker.sh | ./'THIS FILE'S NAME'.sh
+
+awk -F':' '{ 
+
+if(/BitCoin Value/){
+	print $2
+	cmd = "/opt/lampp/bin/mysql -u root -e \"USE cryptoTracker; INSERT INTO cryptoPrice(cryptoID,value,collected) VALUES (1, " $2 ",'\''" strftime("%Y-%m-%d %H:%M:%S") "'\'')\""
+	
+	system(cmd)	
+
+}else if(/BitCoin 24 Hour Low/){
+	print $2
+
+}else if(/BitCoin 24 Hour High/){
+ 	print $2
+
+}else if(/BitCoin 24 Hour Open/){
+        print $2
+
+}else if(/BitCoin Market Cap/){
+        print $2
+
+}else if(/BitCoin Change In Value/){
+        print $2
+
+}else if(/BitCoin Return Percentage/){
+        print $2
+
+}else if(/BitCoin Volatility/){
+        print $2
+
+}else if(/BitCoin 24 H Transaction Count/){
+        print $2
+
+}else if(/BitCoin Transaction Fee/){
+        print $2
+
+}
+
+}' < /dev/stdin
-- 
GitLab