Ved Gupta commited on
Commit
12d36c7
·
1 Parent(s): 3dea319

ROllback added

Browse files
Files changed (1) hide show
  1. app/core/models/Transcribe.py +13 -9
app/core/models/Transcribe.py CHANGED
@@ -34,12 +34,16 @@ class TranscribeController:
34
  self.db = database
35
 
36
  def create(self, user_id: UUID, text: str, duration: int):
37
- self.user_id = user_id
38
- self.text = text
39
- self.audio_duration = duration
40
- self.transcribe_data = TranscibeInDB(
41
- user_id=self.user_id, text=self.text, audio_duration=self.audio_duration
42
- )
43
- self.db.add(self.transcribe_data)
44
- self.db.commit()
45
- self.db.refresh(self.transcribe_data)
 
 
 
 
 
34
  self.db = database
35
 
36
  def create(self, user_id: UUID, text: str, duration: int):
37
+ try:
38
+ self.user_id = user_id
39
+ self.text = text
40
+ self.audio_duration = duration
41
+ self.transcribe_data = TranscibeInDB(
42
+ user_id=self.user_id, text=self.text, audio_duration=self.audio_duration
43
+ )
44
+ self.db.add(self.transcribe_data)
45
+ self.db.commit()
46
+ self.db.refresh(self.transcribe_data)
47
+ except Exception as e:
48
+ self.db.rollback()
49
+ raise e