Re: [Tutor] How to create an object in database only if the object is not already there?

2017-09-11 Thread Albert-Jan Roskam
From: Tutor on behalf of GMX Sent: Monday, September 11, 2017 9:38 AM To: tutor@python.org Subject: [Tutor] How to create an object in database only if the object is not already there? Now when I create a Course object like this:     >>> Course(title=‘A new course’) An object is

Re: [Tutor] How to create an object in database only if the object is not already there?

2017-09-11 Thread Alan Gauld via Tutor
On 11/09/17 10:38, GMX wrote: > I am using `pony` orm to write a simple class as my model. pony is not a standard module (indeed I only heard about it from your email) so you are probably best asking on the pony support forum if such exists or via the author. > from pony.orm import Database > fr

[Tutor] How to create an object in database only if the object is not already there?

2017-09-11 Thread GMX
Hi,  I am using `pony` orm to write a simple class as my model. Here is the class.  ``` from pony.orm import Database from pony.orm import Required, Optional from pony.orm import db_session from pony.orm import select, commit DB_PATH = ‘db.sqlite’ db = Database() class Course(db.Entity):     "