I am attempting to create a chatbot in Python 3.9 using my own text messages, but am having trouble formatting my data correctly. I have a table of text messages that looks like this: row_id Type Date Text 1 Incoming 2020-08-10 08:09:18 Hi 2 Outgoing 2020-08-10 08:11:04 Hello 3 Incoming 2020-08-10 08:11:12 Fo…
Tag: sqlite
how to create a select statement with 2 foreign keys in one table pointing to two different tables
i have 3 tables and one of the tables (itemtag) has two columns each a foreign key pointing to each of the other 2 tables (item and tag). I’m trying to find out how to create a single select statement against this table containing fk’s using values that correspond to one of the other tables. Table…
strftime() with not giving the correct results
I have this table: I need a way to only show records besides the current month and year. example: today is 2021-01-08 I only need to see records besides month 01 and year 2021 This is my sql fiddle playground I do not understand why it doesn’t output the result I want. I need it to show me this: Answer
Sqlite Query to remove duplicates from one column. Removal depends on the second column
Please have a look at the following data example: In this table, I have multiple columns. There is no PRIMARY KEY, as per the image I attached, there are a few duplicates in STK_CODE. Depending on the (min) column, I want to remove duplicate rows. According to the image, one stk_code has three different rows.…
python sqlite3 partial search
I want to do a partial search with python sqlite3. My initial query is: Then I tried using the LIKE keyword and string formatting to obtain partial search results for the title, like this: As in https://stackoverflow.com/a/20904256/13290801 This seems to do the trick for title, but now when searching on the o…
How to add specific number of empty rows in sqlite?
I have a SQLite file and I want to add 2550 empty (NULL) rows. I am able to add one empty line with this code But I need 2550 rows. Is there any shortcut for it? I don’t want to execute same code 2550 times. Answer If your version of SQLite support it, you could use a recursive CTE to
SQLite – order by numbers inside string
its my first post here, so bear with me. I’m trying to order a query by numbers in a specific row that contain letters, using SQLite. Example: “Winter 1993”. I want to be able to sort by the …
How to proprerly bind text to a SQLite prepared statement with sqlite_bind_text
If the following SQL using the sqlite3_prepare_v2 is run, it generates the expected results. select id, path, name from media where id in ( select media_id from media_tags where tag_id in (…
Query slow in Web App, but fast in command line
I am need to retrieve records from two tables which are linked by a third. Session content doesn’t contain any information I need besides the keys to link the other two tables. I am currently using these joins: It only takes 50 ms in SQLite DB browser, but takes multiple seconds of buffering when I call…
How to merge two tables and sum the values with the same ID in SQL?
I am new to SQL sorry if the question ends up being trivial. I have two tables: Table 1 “Clients”: Table 2 “Payments”: Desired Output: Here is what I have tried: This sums the entries in table “payments” with the same ID. However, I don’t know how to use the ID in ord…