Below is my class constructor for eventages
class EventAges:
def init(self, EventAgeName, EventAgeStart, EventAgeEnd):
self.EventAgeName = EventAgeName
self.EventAgeStart = EventAgeStart
self.EventAgeEnd = EventAgeEnd
And this is my func
def add_event_ages(self, event_ages):
query = ”’INSERT INTO EventAges (EventAgeId, EventAgeName, EventAgeStart, EventAgeEnd) VALUES ( ?, ?, ?)”’
values = ( event_ages.EventAgeName, event_ages.EventAgeStart, event_ages.EventAgeEnd)
self.cursor.execute(query, values)
self.connection.commit()
EventAgeId = self.cursor.lastrowid
return EventAgeId
In the database, my fields for EventAges include its Id but I did not include it in my class constructor, since it is already autoincremented,
The problem now is when querying to get the event ages since i also wantt to retrieve the EventAgesId but it is not accepted because it is not in the class constructor
So is there any way for me to include eventagesId in the class constructor while also not needing to manually add the Id when inserting into table
I tried to include event ages Id in the constructor and remove it in the query but it doesnt run since it wants the event ages Id to also be added, Im still not well versed in python with sqlite so Ive been having a hard time with this
Adi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.