In the code I wrote below, the Doktorlar and Hastalar tables are created, the other two tables are not created, what could be the reason for this?
import sqlite3
from flask import config
conn = sqlite3.connect('hospital.db')
c = conn.cursor()
c.execute('pragma foreign_keys=ON')
c.execute('''CREATE TABLE if not exists Hastalar
(hasta_id INTEGER PRIMARY KEY AUTOINCREMENT,
hasta_ad TEXT NOT NULL,
hasta_soyad TEXT NOT NULL,
hasta_cinsiyet TEXT NOT NULL,
hasta_tel TEXT NOT NULL,
hasta_dg DATE NOT NULL,
hasta_adres TEXT );''')
c.execute('''CREATE TABLE if not exists Doktorlar
(doktor_id INTEGER PRIMARY KEY AUTOINCREMENT,
doktor_ad TEXT NOT NULL,
doktor_soyad TEXT NOT NULL,
doktor_uzalan TEXT NOT NULL,
doktor_tel TEXT NOT NULL,
doktor_dg DATE NOT NULL);''')
c.execute('''CREATE TABLE if not exists Randevular
(randevu_id INTEGER PRIMARY KEY AUTOINCREMENT,
randevu_tarih DATE NOT NULL,
doktor_id INTEGER NOT NULL,
hasta_id INTEGER NOT NULL,
FOREIGN KEY(hasta_id) REFERENCES Hastalar(hasta_id)),
FOREIGN KEY(doktor_id) REFERENCES Doktorlar(doktor_id));''')
c.execute('''CREATE TABLE if not exists Raporlar
(rapor_id INTEGER PRIMARY KEY AUTOINCREMENT,
rapor_tarih DATE NOT NULL,
rapor_icerik TEXT NOT NULL,
doktor_id INTEGER NOT NULL,
hasta_id INTEGER NOT NULL,
FOREIGN KEY(hasta_id) REFERENCES Hastalar(hasta_id)),
FOREIGN KEY(doktor_id) REFERENCES Doktorlar(doktor_id));''')
conn.commit()
conn.close()
What should I do to fix it? I would appreciate it if you could help me.
New contributor
Richpoort123 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.