Java, Python, SQL query Practice