Skip to content
Advertisement

Iterating through records with SQL INSERT activated stops after first set of INSERTS, but using PRINT to test goes through EVERY record (as desired)

Python 3.10.2 with sqlite3 on Windows 10. Relatively new to Python, but I was quite experienced with Perl around 1997-2005. Banged my head against this for three days. Attacked from lots of angles. No success. I’m asking for guidance, because I don’t see myself progressing on my own at this point without help flipping on the light-switch. My overall application

Django Model method that uses data from the model

I want to generate unique codes (e.g. “DXGH”) and save it as a field in one of my models. The problem I have is that I do not know how to check against previously generated codes whenever a new object is created. Currently my models.py looks something like this: Ideally I would set the default value of room_code to code_gen_unique,

Method called when an object is deleted

I’m writing a small application in Python 3 where objects (players) hold sets of connected objects of the same type (other players) together with data that belong to the pair of objects (the result of a played game). From time to time it is necessary to delete objects (in my example when they drop out of a tournament). If this

How to create a nest list or a tree view from a flat list based on value condition?

I am working on a problem that given a flat list of strings. But based on the name of the string I would like to create either a nested list, a dictionary or a Node class. Anything that can have a tree structure The string looks something like: [‘big_1’, ‘small_1’, ‘item_1’, ‘item_2’, ‘big_2’, ‘small_2’, ‘item_3’] This should be turned into

creating random values but within another column restraints [python]

I have this type of dataset: I want to have: As you can see, if I just went and created random values for the Gender column, I will eventually have a problem: I might assign different gender names to the same person ID. If I had unique IDs, then, that wouldn’t have been a problem. But I want to create

Advertisement