I have a table in sqlite3
CREATE TABLE exhibit(
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
text1 TEXT NOT NULL,
text2 TEXT,
text3 TEXT,
photo TEXT,
audio TEXT,
video TEXT,
location TEXT NOT NULL);
And I have this code for getting types and names of columns:
def get_columns(obj):
con = sqlite3.connect('mydatabase.db')
with con:
cur = con.cursor()
obj.__str__
sql_req = 'PRAGMA table_info('+obj+');'
cur.execute(sql_req)
data = cur.fetchall()
result1 = []
result2 = []
for d in data:
result1.append(d[1])
result2.append(d[2])
result = []
result.append(result1)
result.append(result2)
#print(result)
if len(result1)>0:
return(1, result)
But in my program I need to know if the type is "NOT NULL" or not. How can I get it? I`m a newcomer in programing and I have no idea:( Please, help