Having these tables into a db: Athlete with fields: athlete_id, name, surname, date_of_birth, height, weight, bio, photo_id AthletePhoto with fields: photo_id, photo, mime_type AthleteResult with fields: athlete_id, gold, silver, bronze Game with fields: game_id, city, year The db model: The code so far can only send data for one of the tables: so it uses that query: SELECT athlete_id, name,
Tag: sqlite
CSV to SQL, but all values are NULL
I am trying to convert a set of relational .csv files to a db with sqlite3: This runs without error and produces a database with the correct tables which have the correct columns. The rows, however, are all NULL for some reason. I have tried debugging the insertion line to see what is going on. I stepped into the executemany()
Can I do a case-based foreign key command (either cascade or set null)?
I would like to give the user the option when he is deleting an item in the parent table, to either cascade delete or set null to the items in the child table that references the foreign key, is that possible within SQLITE? or do I have to do this within my code? These are the commands I currently use
What is the correct syntax for replacements within a SQL string
I am attempting to do a basic search in my sqlite3 database with this JavaScript: This works but is vulnerable to SQL injection. I am trying to get the sqlite replacements parameter to work but I cannot get the syntax right. Sqlite doesn’t want to replace anything within the string literal. What is the correct way to write this so
Overwriting of variable columns in sqlite without string-based construction?
I have a JSON object containing sets of a “keyX” and the corresponding “value”. I need to write the values into a database into the column “keyX”. Unfortunately one can’t format the SQL Query like this: Therefore I’m currently solving it like this: This is working perfectly, but SQL queries shouldn’t be constructed string-based. In this specific case, the keys
Left outer join is working with SQLite while is not with MySQL
I have a table with products, orders, prices, date of sell. I need to create a table with the sells for a product in a single day. I used sqlite and this code worked just fine: /* Groups order date &…
sqlite query python
i want to perform the below query SELECT t1.patient_report, COUNT(*) AS cnt, t1.doctor_report, (SELECT t2.doctor_report FROM infoTable t2 WHERE t2.patient_report = t1.patient_report AND cnt > 1 …
How to join SQL column elements together?
I have an SQL table with the column named expenses like this I want to write a query to return all the elements of this column separated by a comma. For the above example output should be:- hotel,…
AVG() of the quotient of two fields giving unexpected output in SQL
I have a SQL table and I need to find the average of the quotient of two fields (rating, position) grouped by another field (query_name). I cannot make sense of why the following two queries don’t give the same result: Query 1: Query 2: Here is the table: This is the expected output: However, Query 1 gives the following: Answer
SQLite how to use UPDATE and LIMIT at the same time?
What I’m looking for is to update only 1 row in a table where all the entries are, in the beginning, zero. After a while surfing the internet for answers, I found out that LIMIT should work fine with UPDATE, but also not quite. From what I’ve seen, I should have “enabled” some stuff with SQLITE_ENABLE_UPDATE_DELETE_LIMIT, but I have no