2017-10-13 8 views
-1

Je suis confronté à une erreur de fonctionnement lors de l'exécution d'un code sur les lignes ci-dessous de mon code.sqlite3.OperationalError: proche de "FOREIGN": erreur de syntaxe

c.execute("CREATE TABLE IF NOT EXISTS customerReg(cname TEXT,cgender TEXT,cphone INT UNIQUE,cusername TEXT UNIQUE,cpassword TEXT UNIQUE)") 
    c.execute("CREATE TABLE IF NOT EXISTS adminReg(Oname TEXT,Hname TEXT UNIQUE,totalrooms INT,tariff INT,location TEXT,aphone INT,ausername TEXT UNIQUE,apassword TEXT UNIQUE)") 
    c.execute("CREATE TABLE IF NOT EXISTS customerStay(cname TEXT,hostel TEXT,location TEXT,tariff INT)") 
    c.execute("CREATE TABLE IF NOT EXISTS Hostel(FOREIGN KEY(Hostelname) REFERENCE adminReg(Hname),FOREIGN KEY(rent) REFERENCE adminReg(tariff),FOREIGN KEY(roomsavailable) REFERENCE adminReg(totalrooms))") 

L'erreur qui est affiché est

c.execute("CREATE TABLE IF NOT EXISTS Hostel(FOREIGN KEY(Hostelname) 
REFERENCE adminReg(Hname),FOREIGN KEY(rent) REFERENCE 
adminReg(tariff),FOREIGN KEY(roomsavailable) REFERENCE 
adminReg(totalrooms))") sqlite3.OperationalError: near "FOREIGN": 
syntax error 

Je ne suis pas en mesure de voir l'erreur.

Répondre

0

Cette instruction CREATE TABLE ne définit aucune colonne. (FOREIGN KEY déclare une contrainte sur une colonne existante, elle ne définit pas une nouvelle colonne.)

Et REFERENCES est mal orthographié.