Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- database = mysql.connect(user='erel17', # STUDENT_ID
- passwd='SHwLUTtghp5C', # Losenord
- database='erel17', # STUDENT_ID
- host='blu-ray.student.bth.se')
- c = database.cursor(dictionary=True)
- c.execute("select distinct gender from Product")
- record = c.fetchall()
- print("Total number of rows in python_developers is - ", c.rowcount)
- for row in record:
- print(row['gender'])
- print("hej på dig")
- ## Hämtar vi könen som finns
- df = pd.read_csv(cmd_folder + 'data/Products.csv')
- genders = [record[0]['gender'],record[1]['gender']]
- types = [
- df[(df['gender'] == genders[0])]['type'].unique().tolist(),
- df[(df['gender'] == genders[1])]['type'].unique().tolist()
- ]
- c.execute("select ProductCategoryName from Product join ProductType on Product.ProductTypeId = ProductType.ProductTypeId join ProductCategory on ProductType.ProductCategoryId = ProductCategory.ProductCategoryId where gender = 'female' group by ProductCategoryName")
- recordFemale = c.fetchall()
- c.execute("select ProductCategoryName from Product join ProductType on Product.ProductTypeId = ProductType.ProductTypeId join ProductCategory on ProductType.ProductCategoryId = ProductCategory.ProductCategoryId where gender = 'Male' group by ProductCategoryName")
- recordMale = c.fetchall()
- for row in recordFemale:
- print(row['ProductCategoryName'])
- children = [[{
- 'url': '',
- 'name': row['ProductCategoryName']
- } for row in recordFemale], [{
- 'url': '',
- 'name': row['ProductCategoryName']
- } for row in recordMale]]
- ''' SQL '''
- result = [{
- 'title': genders[0],
- 'children': children[0]
- }, {
- 'title': genders[1],
- 'children': children[1]
- }]
- return result
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement