diff --git a/.idea/count_skills.py b/.idea/count_skills.py new file mode 100644 index 0000000..7c3f471 --- /dev/null +++ b/.idea/count_skills.py @@ -0,0 +1,10 @@ +cursor.execute('SELECT COUNT(*) FROM works where skills not null') +print(cursor.fetchall()[0][0]) + +# Получить заполненные скиллы. +cursor.execute('SELECT skills FROM works where skills not null') +print(cursor.fetchall()) + +# Вывести зарплату только у тех, у кого в скилах есть Python +cursor.execute('SELECT salary FROM works where skills LIKE "%Python%"') +print(cursor.fetchall()) \ No newline at end of file diff --git a/.idea/dz.py b/.idea/dz.py new file mode 100644 index 0000000..06844ac --- /dev/null +++ b/.idea/dz.py @@ -0,0 +1,66 @@ +import numpy as np +import pandas as pd +import sqlite3 +import matplotlib.pyplot as plt +import re + + +def get_clean_field(field): + return re.sub(r'\<[^>]*\>', '', str(field)) + +fail = sqlite3.connect('works.sqlite') +cursor = fail.cursor() +cursor.execute('удалить таблицу, если она существует') +cursor.execute('create table works (' + 'ID INTEGER PRIMARY KEY AUTOINCREMENT,' + 'salary INTEGER,' + 'educationType TEXT,' + 'jobTitle TEXT,' + 'qualification TEXT,' + 'gender TEXT,' + 'dateModify TEXT,' + 'skills TEXT,' + 'otherInfo TEXT)') +fail.commit() + +read_fail = pd.read_csv("works.csv") +read_fail['skills'] = read_fail['skills'].apply(get_clean_field) +read_fail['otherInfo'] = read_fail['otherInfo'].apply(get_clean_field) +read_fail.to_sql("works", fail, if_exists='append', index=False) +fail.commit() + + +# ДЗ +cursor.execute('удалить таблицу, если существуют гендерные категории') +cursor.execute('create table genders(id integer primary key autoincrement, gender_val)') +fail.commit() + +cursor.execute('insert into genders(gender_val) select distinct gender from works where gender is not null') +fail.commit() + +cursor.execute('alter table works add column gender_id integer references genders(id)') +fail.commit() + +cursor.execute('update works set gender_id = (select id from genders where gender_val = works.gender)') +fail.commit() + +cursor.execute('table works drop column gender') +fail.commit() + + + +cursor.execute('удалить таблицу, если существует образование') +cursor.execute('create table education(id integer primary key autoincrement, education_val text)') +fail.commit() + +cursor.execute('insert into education(education_val) select distinct educationType from works where educationType is not null') +fail.commit() + +cursor.execute('alter table works add column educationType_id integer references education(id)') +fail.commit() + +cursor.execute('update works set educationType_id = (select id from genders where education_val = works.educationType)') +fail.commit() + +cursor.execute('table works drop column educationType') +fail.commit() \ No newline at end of file diff --git a/.idea/men_women_zp.py b/.idea/men_women_zp.py new file mode 100644 index 0000000..5b0cb47 --- /dev/null +++ b/.idea/men_women_zp.py @@ -0,0 +1,5 @@ +plt.plot(np.linspace(0.1, 1, 10), m_salary) +plt.plot(np.linspace(0.1, 1, 10), w_salary) +plt.xlabel("Перцентили") +plt.ylabel("Зарплата") +plt.show() \ No newline at end of file diff --git a/.idea/para.py b/.idea/para.py new file mode 100644 index 0000000..1c354de --- /dev/null +++ b/.idea/para.py @@ -0,0 +1,14 @@ +cursor.execute('create index salary_index on works (salary)') +con.commit() + +# количество всех записей +ursor.execute('SELECT COUNT(*) FROM works') +print(cursor.fetchall()[0][0]) + +# men +cursor.execute('SELECT COUNT(*) FROM works where gender = "Мужской"') +print(cursor.fetchall()[0][0]) + +# women +cursor.execute('SELECT COUNT(*) FROM works where gender = "Женский"') +print(cursor.fetchall()[0][0]) \ No newline at end of file diff --git a/.idea/para_2sposob.py b/.idea/para_2sposob.py new file mode 100644 index 0000000..71fcea5 --- /dev/null +++ b/.idea/para_2sposob.py @@ -0,0 +1,2 @@ +cursor.execute('SELECT gender, COUNT(*) FROM works group by gender') +print(cursor.fetchall()) \ No newline at end of file diff --git a/.idea/works.sqlite b/.idea/works.sqlite new file mode 100644 index 0000000..331a6bb --- /dev/null +++ b/.idea/works.sqlite @@ -0,0 +1,7 @@ +SELECT * FROM 'education' LIMIT 0,30 + +SELECT * FROM 'genders' LIMIT 0,30 + +SELECT * FROM 'sqlite_sequence' LIMIT 0,30 + +SELECT * FROM 'works' LIMIT 0,30