first commit

This commit is contained in:
jpez 2022-03-21 22:55:30 +00:00
commit 739329605e
2 changed files with 67 additions and 0 deletions

59
OracleSQL.py Normal file
View File

@ -0,0 +1,59 @@
import os
import subprocess as sp
from time import sleep
accounts = ["username", "username"]
os.chdir("C://Users/joshu/Documents/Uni/CSY1026/scripts/")
runFlag = True
while runFlag:
choice = int(input("\nWhich account would you like to log into?\n1) Normal\n2) Coursework\n>"))
if (choice == 1 or choice == 2):
runFlag = False
else:
print("\nIncorrect Input\n")
input("Press Enter to continue...\n")
print("\nHere are your available scripts:\n")
files = [f for f in os.listdir(".") if os.path.isfile(f)]
runFlag = True
while runFlag:
os.chdir("C://Users/joshu/Documents/Uni/CSY1026/scripts/")
for i in range(0,len(files)):
print(files[i][:len(files[i])-4])
choice = input("\nWhat would you like to do? \nform: 'command file'\n\nCommands:\nedit\nedit folder\nrun\nquit\n> ")
if (choice == "quit"):
runFlag = False
break
try:
split_choice = choice.rsplit(" ",1)
command = split_choice[0]
current_file = split_choice[1]
except IndexError:
print ("\nIncorrect Input\n")
input("Press Enter to continue...\n")
continue
if (command == "edit"):
if (current_file == "folder"):
os.system("code --n .")
else:
os.system(f"code {current_file}.sql")
elif (command == "run"):
os.chdir("C://Oracle12c/")
run_time = ""
if (choice == 1 or choice == 2):
run_time = sp.Popen(f"sqlplus.exe {accounts[choice-1]}@student/password", stdout=sp.PIPE, stdin=sp.PIPE, stderr=sp.PIPE)
print("\n"+run_time.communicate(f"@C://Users/joshu/Documents/Uni/CSY1026/scripts/{current_file}.sql\n".encode())[0].decode())
input("Press Enter to continue...\n")
else:
print("\nIncorrect Input\n")
input("Press Enter to continue...\n")

8
README.md Normal file
View File

@ -0,0 +1,8 @@
# CSY1026_cli_ide
This code was to made to make accessing my university CSY1026 module database server easier and also allowed the running of scripts.
Editing was also made possible by opening the files in vscode.
All operations are achieved using native libraries os and subprocess
This code is not usable unless you have been given the specific binaries from the module tutors at the University of Northampton