SQL search many conditions must return one row

Problem is that i get a whole bunch of users, that does not match the search string no matter what i search. And it seems like there is baseline of users that is allways passed. I cant figure out what exactly it is finding, but the lenght of the return of users vary depending on… Read More SQL search many conditions must return one row

How to close database sqlite3 in class?

i have recently started exploring DataBases. i cant solve a task: i have a class that makes changes in my DataBase(sqlite3). i dont know how to close correctly db connection. i thought and find a decission. is this optimal and correct? class DBConnection: def __enter__(self): self.conn = sqlite3.connect(‘main.db’) self.cursor = self.conn.cursor() return self.cursor def __exit__(self):… Read More How to close database sqlite3 in class?

Output data without duplicates by maximum date

I have two tables: Test1 and Test2. Test1: Cat Dog Date 123412 1111111 2023-01-01 12:01:01 123412 2222222 2023-01-01 13:02:01 Test2 Cat Parrot Date 123412 1412111 2023-01-01 14:01:01 123412 2242222 2023-01-01 15:02:01 The script for joining these tables looks like this: select test1.cat test2.cat from Test1 test1 left join Test2 test2 on test2.cat=test1.cat It is necessary… Read More Output data without duplicates by maximum date