[PyQt] Nullable foreign keys

Simone simozack at yahoo.it
Fri Mar 28 07:59:57 GMT 2008


Catriona Johnson ha scritto:

> My question is how do I handle nullable foreign keys? If foreign key
> is null it is not being displayed in the QTableView and there seems to
> be no way of having a null value in a combo box apart from having a
> 'Null' record which I don't really want to do.

I solve this issue by inserting a row with the ID field -1 and the rest 
of the columns as null except where there is a foreign key, in which I 
insert the value of -1.

My bad english plays against me, so consider this example:

table_1:

ID integer primary key autoincrement,
DESCRIPTION text,
FK_TO_TABLE_2 integer;

TABLE_2:

ID integer primary key autoincrement,
DESCRIPTION text;

The inserted rows are:

TABLE_2:

insert into TABLE_2(ID) values (-1);

TABLE_1:

insert into TABLE_1(ID, FK_TO_TABLE_2) values (-1, -1);

HTH!
Simone

Chiacchiera con i tuoi amici in tempo reale! 
 http://it.yahoo.com/mail_it/foot/*http://it.messenger.yahoo.com 



More information about the PyQt mailing list