[Tutor] sqlite3 Dilemma

Peter Otten __peter__ at web.de
Mon Jul 30 20:17:11 CEST 2012


Khalid Al-Ghamdi wrote:

> I am a teacher at an industrial training center. We have to conduct
> hands-on exams (fixing pumps, etc). I review all the test schedules for
> all the students (made by other teachers) to make sure there are no
> clashes due to lack of ample supply of equipment or tools. Meaning no two
> trainees are to have the same test at the same time. If this is the case,
> then the date or time or test code have to be changed to avoid the
> conflict.
> 
> I have the schedule in csv format. I have been able to export it to
> sqlite3 as seen below and I have found all the conflicts, too.
> 
> My dilemma is how to go about making sqlite3 alter the date, time, or exam
> code if another trainee is scheduled at the same time and date with the
> same test code.
> 
> What is the proper approach to handle this?

I think what you have is a "constraint satisfaction problem". There are 
packages in Python that address it, but I have no experience with them and 
therefore cannot make any recommendations. This one

http://pypi.python.org/pypi/constraint/

...has an example similar to your problem which may help you get started:

http://www.logilab.org/3441

> I'm using python 3 on windows.

I see no mention of Python 3 on their site, so you probably have to resort 
to Python 2 should you end up with the solver mentioned above.

> Below is how far I've gotten.

I'd forget the database for the moment, but keep the code to verify the 
solution once you have arrived at it through other means.



More information about the Tutor mailing list