Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
task_2_crm/python_files/credentials.json
task_2_crm/python_files/token.json
136 changes: 136 additions & 0 deletions task_1/task1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
import psycopg2

try:
con = psycopg2.connect(
dbname = "postgres",
user = "postgres",
password = "sunset2014",
host = "localhost",
port = "5432"
)
cur = con.cursor()
cur.execute('''
create table if not exists employees_table(
emp_id bigint primary key,
first_name varchar(50),
last_name varchar(50),
salary integer,
job_title varchar(50),
gender varchar(10),
hire_date date
)
''')
rows = [
(17679, 'Robert', 'Gilmore', 110000, 'Operations Director', 'Male', '2018-09-04'),
(26650, 'Elvis', 'Ritter', 86000, 'Sales Manager', 'Male', '2017-11-24'),
(30840, 'David', 'Barrow', 85000, 'Data Scientist', 'Male', '2019-12-02'),
(49714, 'Hugo', 'Forester', 55000, 'IT Support Specialist', 'Male', '2019-11-22'),
(51821, 'Linda', 'Foster', 95000, 'Data Scientist', 'Female', '2019-04-29'),
(67323, 'Lisa', 'Wiener', 75000, 'Business Analyst', 'Female', '2018-08-09'),
(70950, 'Rodney', 'Weaver', 87000, 'Project Manager', 'Male', '2018-12-20'),
(71329, 'Gayle', 'Meyer', 77000, 'HR Manager', 'Female', '2019-06-28'),
(76589, 'Jason', 'Christian', 99000, 'Project Manager', 'Male', '2019-01-21'),
(97927, 'Billie', 'Lanning', 67000, 'Web Developer', 'Female', '2018-06-25')
]
cur.executemany("""
INSERT INTO employees_table (emp_id, first_name, last_name, salary, job_title, gender, hire_date)
VALUES (%s, %s, %s, %s, %s, %s, %s)
ON CONFLICT (emp_id) DO NOTHING;
""", rows)

cur.execute('''
CREATE TABLE IF NOT EXISTS departments_table (
emp_id BIGINT,
dept_name VARCHAR(50),
dept_id INTEGER,
PRIMARY KEY (emp_id, dept_id)
)
''')
rows2 = [
(17679, 'Operations', 13),
(26650, 'Marketing', 14),
(30840, 'Operations', 13),
(49823, 'Technology', 12),
(51821, 'Operations', 13),
(67323, 'Marketing', 14),
(71119, 'Administrative', 11),
(76589, 'Operations', 13),
(97927, 'Technology', 12)
]
cur.executemany("""
INSERT INTO departments_table (emp_id, dept_name, dept_id)
VALUES (%s, %s, %s)
ON CONFLICT (emp_id, dept_id) DO NOTHING;
""", rows2)
con.commit()
except Exception as e:
print(f"connection failed:{e}")

# sorgular

print("________________question1_______________")
query_1 = "select * from employees_table where salary > (select salary from employees_table where first_name = 'Rodney' and last_name = 'Weaver')"
cur.execute(query_1)
question1 = cur.fetchall()
print(question1)
print("________________question2_______________")
query_2 = "select (min(salary)+max(salary))/2 from employees_table"
cur.execute(query_2)
question2 = cur.fetchall()
print(question2)
print("________________question3_______________")
query_3 = """SELECT first_name, last_name, salary FROM public.employees_table
where salary > 8700;"""
cur.execute(query_3)
question3 = cur.fetchall()
print(question3)
print("________________question4_______________")
query_4 = """SELECT first_name, last_name from employees_table
where emp_id in (select emp_id from departments_table)"""
cur.execute(query_4)
question4 = cur.fetchall()
print(question4)
print("________________question5_______________")
query_5 = """SELECT first_name, last_name from employees_table
where emp_id in (select emp_id from departments_table where dept_name = 'Technology')"""
cur.execute(query_5)
question5 = cur.fetchall()
print(question5)
print("________________question6_______________")
query6 = """select avg(salary) from employees_table
where gender = 'Female'"""
query_6 = """select avg(salary) from employees_table
where gender = 'Female'"""
cur.execute(query_6)
question6 = cur.fetchall()
print(question6)
print("________________question7_______________")
query7 = """SELECT dept_name, AVG(salary) AS avg_salary
FROM employees_table e
JOIN departments_table d
ON e.emp_id = d.emp_id
GROUP BY d.dept_name;
"""
cur.execute(query7)
question7 = cur.fetchall()
print(question7)
print("________________question8_______________")
query_8 = """select max(hire_date), min(hire_date) from employees_table"""
cur.execute(query_8)
question8 = cur.fetchall()
print(question8)
print("________________question9_______________")
query9 = """select hire_date, dept_name from employees_table e
join departments_table d on e.emp_id = d.emp_id
where e.salary = (select max(salary) from employees_table)"""
cur.execute(query9)
question9 = cur.fetchall()
print(question9)
print("________________question10_______________")
query10 = """select hire_date from employees_table where salary = (select min(salary) from employees_table)"""
cur.execute(query10)
question10 = cur.fetchall()
print(question10)

cur.close()
con.close()
114 changes: 114 additions & 0 deletions task_2_crm/python_files/PrefenceAdminMenu.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# Form implementation generated from reading ui file 'PrefenceAdminMenu.ui'
#
# Created by: PyQt6 UI code generator 6.8.0
#
# WARNING: Any manual changes made to this file will be lost when pyuic6 is
# run again. Do not edit this file unless you know what you are doing.


from PyQt6 import QtCore, QtGui, QtWidgets
import subprocess

class Ui_Form_Admin(object):
def setupUi(self, Form):
Form.setObjectName("Form")
Form.setEnabled(True)
Form.resize(670, 524)
self.gridLayout = QtWidgets.QGridLayout(Form)
self.gridLayout.setObjectName("gridLayout")
self.pushButton_Applications = QtWidgets.QPushButton(parent=Form)
self.pushButton_Applications.setObjectName("pushButton_Applications")
self.gridLayout.addWidget(self.pushButton_Applications, 2, 1, 1, 1)
spacerItem = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Expanding)
self.gridLayout.addItem(spacerItem, 0, 0, 1, 1)
self.pushButton_Interviews = QtWidgets.QPushButton(parent=Form)
self.pushButton_Interviews.setObjectName("pushButton_Interviews")
self.gridLayout.addWidget(self.pushButton_Interviews, 4, 1, 1, 1)
self.pushButton_Exit = QtWidgets.QPushButton(parent=Form)
self.pushButton_Exit.setEnabled(True)
self.pushButton_Exit.setObjectName("pushButton_Exit")
self.gridLayout.addWidget(self.pushButton_Exit, 6, 2, 1, 1)
self.pushButton_Mentor_Meeting = QtWidgets.QPushButton(parent=Form)
self.pushButton_Mentor_Meeting.setEnabled(True)
self.pushButton_Mentor_Meeting.setObjectName("pushButton_Mentor_Meeting")
self.gridLayout.addWidget(self.pushButton_Mentor_Meeting, 3, 1, 1, 1)
spacerItem1 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Expanding)
self.gridLayout.addItem(spacerItem1, 6, 1, 1, 1)
self.pushButton_Main_Menu = QtWidgets.QPushButton(parent=Form)
self.pushButton_Main_Menu.setObjectName("pushButton_Main_Menu")
self.gridLayout.addWidget(self.pushButton_Main_Menu, 6, 0, 1, 1)
self.title = QtWidgets.QLabel(parent=Form)
font = QtGui.QFont()
font.setPointSize(14)
font.setBold(False)
font.setItalic(False)
font.setWeight(50)
font.setStrikeOut(False)
self.title.setFont(font)
self.title.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter)
self.title.setObjectName("title")
self.gridLayout.addWidget(self.title, 1, 0, 1, 3)
self.pushButton = QtWidgets.QPushButton(parent=Form)
self.pushButton.setEnabled(True)
self.pushButton.setObjectName("pushButton")
self.gridLayout.addWidget(self.pushButton, 5, 1, 1, 1)

self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)

self.pushButton_Applications.clicked.connect(self.open_applications)
self.pushButton_Mentor_Meeting.clicked.connect(self.open_mentormeeting)
self.pushButton_Interviews.clicked.connect(self.open_interviews)
self.pushButton.clicked.connect(self.open_adminmenu)
self.pushButton_Main_Menu.clicked.connect(self.open_mainmenu)
self.pushButton_Exit.clicked.connect(self.exit)

def retranslateUi(self, Form):
_translate = QtCore.QCoreApplication.translate
Form.setWindowTitle(_translate("Form", "Form"))
self.pushButton_Applications.setText(_translate("Form", "APPLICATIONS"))
self.pushButton_Interviews.setText(_translate("Form", "INTERWIEWS"))
self.pushButton_Exit.setText(_translate("Form", "EXIT"))
self.pushButton_Mentor_Meeting.setText(_translate("Form", "MENTOR MEETING"))
self.pushButton_Main_Menu.setText(_translate("Form", "MAIN MENU"))
self.title.setText(_translate("Form", "PREFENCE ADMIN MENU"))
self.pushButton.setText(_translate("Form", "ADMIN MENU"))


def open_applications(self):
appPath = r"task_2_crm\python_files\applications_page.py"
subprocess.Popen(["python", appPath])
QtWidgets.QApplication.instance().quit()

def open_mentormeeting(self):
MentorPath = r'task_2_crm\python_files\mentor_interview.py'
subprocess.Popen(["python", MentorPath])
QtWidgets.QApplication.instance().quit()

def open_interviews(self):
interviewsPath = r'task_2_crm\python_files\interviews.py'
subprocess.Popen(["python", interviewsPath])
QtWidgets.QApplication.instance().quit()

def open_adminmenu(self):
adminPath = r"task_2_crm\python_files\adminmenu.py"
subprocess.Popen(["python", adminPath])
QtWidgets.QApplication.instance().quit()

def open_mainmenu(self):
loginPath = r"task_2_crm\python_files\loginscreen.py"
subprocess.Popen(["python", loginPath])
QtWidgets.QApplication.instance().quit()

def exit(self):
QtWidgets.QApplication.instance().quit()


if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
Form = QtWidgets.QWidget()
ui = Ui_Form_Admin()
ui.setupUi(Form)
Form.show()
sys.exit(app.exec())
102 changes: 102 additions & 0 deletions task_2_crm/python_files/PrefenceMenu.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# Form implementation generated from reading ui file 'PrefenceMenu.ui'
#
# Created by: PyQt6 UI code generator 6.8.0
#
# WARNING: Any manual changes made to this file will be lost when pyuic6 is
# run again. Do not edit this file unless you know what you are doing.


from PyQt6 import QtCore, QtGui, QtWidgets
import subprocess


class Ui_Form(object):
def setupUi(self, Form):
Form.setObjectName("Form")
Form.setEnabled(True)
Form.resize(670, 496)
self.gridLayout = QtWidgets.QGridLayout(Form)
self.gridLayout.setObjectName("gridLayout")
self.pushButton_Mentor_Meeting = QtWidgets.QPushButton(parent=Form)
self.pushButton_Mentor_Meeting.setObjectName("pushButton_Mentor_Meeting")
self.gridLayout.addWidget(self.pushButton_Mentor_Meeting, 3, 1, 1, 1)
self.pushButton_Interviews = QtWidgets.QPushButton(parent=Form)
self.pushButton_Interviews.setObjectName("pushButton_Interviews")
self.gridLayout.addWidget(self.pushButton_Interviews, 4, 1, 1, 1)
self.pushButton_Exit = QtWidgets.QPushButton(parent=Form)
self.pushButton_Exit.setEnabled(True)
self.pushButton_Exit.setObjectName("pushButton_Exit")
self.gridLayout.addWidget(self.pushButton_Exit, 5, 2, 1, 1)
self.pushButton_Main_Menu = QtWidgets.QPushButton(parent=Form)
self.pushButton_Main_Menu.setObjectName("pushButton_Main_Menu")
self.gridLayout.addWidget(self.pushButton_Main_Menu, 5, 0, 1, 1)
self.title = QtWidgets.QLabel(parent=Form)
font = QtGui.QFont()
font.setPointSize(14)
font.setBold(False)
font.setItalic(False)
font.setWeight(50)
font.setStrikeOut(False)
self.title.setFont(font)
self.title.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter)
self.title.setObjectName("title")
self.gridLayout.addWidget(self.title, 1, 0, 1, 3)
self.pushButton_Applications = QtWidgets.QPushButton(parent=Form)
self.pushButton_Applications.setObjectName("pushButton_Applications")
self.gridLayout.addWidget(self.pushButton_Applications, 2, 1, 1, 1)
spacerItem = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Expanding)
self.gridLayout.addItem(spacerItem, 5, 1, 1, 1)
spacerItem1 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Expanding)
self.gridLayout.addItem(spacerItem1, 0, 0, 1, 1)

self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)

self.pushButton_Applications.clicked.connect(self.open_applications)
self.pushButton_Mentor_Meeting.clicked.connect(self.open_mentormeeting)
self.pushButton_Interviews.clicked.connect(self.open_interviews)
self.pushButton_Main_Menu.clicked.connect(self.open_mainmenu)
self.pushButton_Exit.clicked.connect(self.exit)

def retranslateUi(self, Form):
_translate = QtCore.QCoreApplication.translate
Form.setWindowTitle(_translate("Form", "Form"))
self.pushButton_Mentor_Meeting.setText(_translate("Form", "MENTOR MEETING"))
self.pushButton_Interviews.setText(_translate("Form", "INTERWIEWS"))
self.pushButton_Exit.setText(_translate("Form", "EXIT"))
self.pushButton_Main_Menu.setText(_translate("Form", "MAIN MENU"))
self.title.setText(_translate("Form", "PREFENCE MENU"))
self.pushButton_Applications.setText(_translate("Form", "APPLICATIONS"))

def open_applications(self):
appPath = r'task_2_crm\python_files\applications_page.py'
subprocess.Popen(["python", appPath])
Form.close()

def open_mentormeeting(self):
MentorPath = r'task_2_crm\python_files\mentor_interview.py'
subprocess.Popen(["python", MentorPath])
Form.close()

def open_interviews(self):
interviewsPath = r'task_2_crm\python_files\interviews.py'
subprocess.Popen(["python", interviewsPath])
Form.close()

def open_mainmenu(self):
loginPath = r"task_2_crm\python_files\loginscreen.py"
subprocess.Popen(["python", loginPath])
Form.close()

def exit(self):
Form.close()


if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
Form = QtWidgets.QWidget()
ui = Ui_Form()
ui.setupUi(Form)
Form.show()
sys.exit(app.exec())
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading