Problem running SQL statements in 244

Back to General discussions forum

rafael.adorna     2022-01-22 10:32:27
User avatar

Hi team,

I've got the query working correctly against a SQLite DB in my local environment but the answer inserted keeps being incorrect. Any way of validating this? Getting more test data would be nice but also getting the versions of the DB and environment so I can try to replicate what's going on.

Regards

gardengnome     2022-01-22 11:46:27
User avatar

Hi, just checking, are you using substr() or substring() by any chance? There are small differencen between versions of SQLite.

rafael.adorna     2022-01-22 12:05:51
User avatar

Hi gardengnome,

Thanks for your reply. I am indeed using SUBSTR... Do you think this could cause an issue between versions? Do you know they version we are using in the Abbey?

gardengnome     2022-01-22 12:34:56
User avatar

Not sure about the version. There is an earlier thread Couple problems on SQL - 244 and 245 that discusses some aspects of the version. I asked about substring in particular as that was a problem I had - substr should work fine.

rafael.adorna     2022-01-22 12:50:10
User avatar

Hi gardengnome,

Kudos for the info. I already checked that entry but I am using SUBSTR and not SUBSTRING so I don't think it applies to my situation.

rafael.adorna     2022-01-22 13:08:16
User avatar

I get also the same error for task 245: "Your query is expected to start with SELECT keyword" It does, indeed, start with the "SELECT" keyword capitalized...

Rodion (admin)     2022-01-22 15:51:01
User avatar

Hi Friend!

Your solution for #245 starts with

import sqlite3
from sqlite3 import Error
import os, sys


def create_connection(db_file):
    """ create a database connection to the SQLite database
        specified by
...

This is not exactly sql and doesn't start with "select" :)

For these problems you need only sent SQL query as solution.

As about versions - yep, the server version of sqlite is somewhat older. Not found good way to update it yet, sorry.

rafael.adorna     2022-01-22 17:29:17
User avatar

Hi Rodion,

Thanks a lot for your reply. It wasn't clear to me that I needed to put only the SQL in the code snippet reserved for the solution (Not the answer form, as a clarification in case anyone is reading this). With that information I was able to progress and solve 245.

Thanks a lot for your time and have a great weekend! (You too, gardengnome)

CondorHunter     2022-01-27 22:37:16

I'm still having a tough time figuring out how to submit the answer. Everything works fine on SQL Fiddle, but still getting "wrong answer"/more results than expected.

Rodion (admin)     2022-01-28 06:06:50
User avatar

Hi Friend!

more results than expected.

This probably means that almost all is ok, just your filtering is probably not correct and your select returns, as said, more results than needed.

CondorHunter     2022-01-28 18:34:23

>.< I realize now what I did wrong. I failed to read the statement closely enough. My apologies.

Rodion (admin)     2022-01-28 19:25:52
User avatar

Oh, no problem with it :) I guess the error message could be improved to make meaning more clear - shall try to think about it!

DavidCamiloMora     2022-04-16 03:03:41

I have the same problem I keep getting more results than expected. I read all the post in the forum about the problem. I use substr and everything runs fine on fiddle too and in the webpagge.

I have checked my logic multiple times, re read the stament and more. I can't realice what is wrong I tried my own tests and it works.

:( thank you for reading.

Edit it was a problem with my logic, no being able to see the test that the servers does can be problematic, but i think is part of the challenge. Fun problem!

Please login and solve 5 problems to be able to post at forum