I am learning to create a database with python. I am using this line of code to populate my table T.insert(2, 'Jones', 'Jack', 15, False, 0.0)
And the table is created as follow:
T = SDBTable('id=ui', 'last', 'first', 'age=i', 'married=b', 'salary=f')
I have a class SDBTable and in it there are several methods I have to implement. The first one being def __init__(self, *fields):
in which I should create a table with parameters defining valid fields/columns in
the table. There is at least one parameter. (Field should specifiers have a name and an option attribute)
I have been searching the web for example of defining the fields for a table in Python but i cannot find any. If anyone can provide help I would really appreciate it.
I tried something like this in defining my fields. Is this at all correct?
self.uid=id
self.last=last
self.first=first
self.age=age
self.married=married
self.salary=salary
there is a test for this method written as:
for f in fields:
# test the format and determine name, unique, and type
# ...
self.__fields.append('field_name')
self.__specs.append((True, str))
which I am suppose to test if the field is unique, the name of it, and what type it is.
Please help me understand. I am a beginner to learning Python.
Thank you