Categories
Database Development

Postgres query performance – hash aggregate costly operation

I’m running Postgres 9.6.6 and I have a relatively simple query, however, I’m finding that it is slow with the hash aggregation function which is the most costly operation: select program_schedule_source_count.full_name, program_schedule_source_count.country, sum(program_schedule_source_count.displays) as displays, program_schedule_source_count.source_id, program_schedule_source_count.source_region from program_schedule_source_count where program_schedule_source_count.original_title = ‘How I Met Your Mother’ and program_schedule_source_count.show_type in (‘SM’, ‘SE’) and program_schedule_source_count.start_date between […]

Categories
Mastering Development

How can i handle django nested models?

I have a User, Post and Tag model in Django. Tag model is not relevant for this topic. I am trying to get all the data in the front end with nested objects. I can succesfully did that.When i want to create a new post i send the post data to django and in django […]

Categories
Mastering Development

I’m trying to send data to a parent table and also one of its three child tables. Only one of the child tables work and i cant figure out why

I’m using MySQL and PHP with XAMPP. I can not figure out if this is a problem with my database or with my PHP. In lines 28-96 (i made a comment in the code so you can see which ones I’m referring to) The capstone child table works. If I select capstone as the project […]

Categories
Development

Rails 6 AssociationTypeMismatch with fields_for

Don’t know why this want work ? Please help. Rails 6 class Tjedan < ApplicationRecord has_many :termini accepts_nested_attributes_for :termini end class Termin < ApplicationRecord belongs_to :tjedan belongs_to :barber belongs_to :pon, class_name: ‘Smjena’, foreign_key: ‘pon’ belongs_to :uto, class_name: ‘Smjena’, foreign_key: ‘uto’ end class Smjena < ApplicationRecord has_many :barberi has_many :termini end Controller has params.require(:tjedan).permit(:status, :start_date, termini_attributes: […]

Categories
Development

How to convert a list of tuples to a csv file

Very new to programming and was trying to create an amortization table. Found some great questions and answers on here, but now I am stuck trying to convert the results into a csv file. from datetime import date from collections import OrderedDict from dateutil.relativedelta import * import csv def amortization_schedule(rate, principal, period): start_date=date.today() #defining the […]

Categories
Development

fail to update the table based on checked value

I’ve a listview from the database with checkbox. My objectives is to insert the checked listview into a table and update another table based on the checked listview. Unfortunately, my SQL query did not work in the section. Here is my full code: package com.example.myapplication; import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.text.DateFormat; […]

Categories
Development

Storing Default Prices and Adjusted Prices

I am designing a database for a retail company. Products can have many prices, and prices can be different for different customers. I am deciding between two options which I will layout below. With which design would it be easier to see if an adjusted price exists for some product/customer pair and then use that […]

Categories
Development

Is there a way to format date from excel recordset

I get data from SQL Server and now I want to copy it in Excel worksheet. I try to format “start_date” but it apply format only on the first column, all other display as stored in SQL Server. Could you please suggest code modifying? Sub ReadMBDataFromSQL() Dim Server_Name, Database_Name, User_ID, Password, SQLStr As String Set […]

Categories
Development

How to get trading hours for shop

I wish to get the trading hours for a shop. My schema represents the opening time, and the duration which the shop is open, which is quite trivial. An override table is provided to store dates which differ from the standard trading hours, or if the store is closed on a given day, or days. […]

Categories
Development

mpl_finance candlestick colordown argument not working

I’m fallowing this tutorial for charting stock data via mpl_finance. I’m having trouble displaying the ‘colordown’ argument in the command candlestick_ohlc(ax1, candleAr, width=1, colorup=’g’, colordown=’r’). when I run my code (below) it successfully runs, but it outputs this chart where all the ups&downs for the candlesticks all display as green instead of ups as green […]