Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1#!/usr/bin/env python 

2 

3""" 

4camcops_server/cc_modules/cc_dirtytables.py 

5 

6=============================================================================== 

7 

8 Copyright (C) 2012-2020 Rudolf Cardinal (rudolf@pobox.com). 

9 

10 This file is part of CamCOPS. 

11 

12 CamCOPS is free software: you can redistribute it and/or modify 

13 it under the terms of the GNU General Public License as published by 

14 the Free Software Foundation, either version 3 of the License, or 

15 (at your option) any later version. 

16 

17 CamCOPS is distributed in the hope that it will be useful, 

18 but WITHOUT ANY WARRANTY; without even the implied warranty of 

19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

20 GNU General Public License for more details. 

21 

22 You should have received a copy of the GNU General Public License 

23 along with CamCOPS. If not, see <https://www.gnu.org/licenses/>. 

24 

25=============================================================================== 

26 

27**Representation of a "dirty table" -- one that a device is in the process of 

28uploading to/preserving.** 

29 

30""" 

31 

32from sqlalchemy.schema import Column, ForeignKey 

33from sqlalchemy.sql.sqltypes import Integer 

34 

35from camcops_server.cc_modules.cc_device import Device 

36from camcops_server.cc_modules.cc_sqla_coltypes import TableNameColType 

37from camcops_server.cc_modules.cc_sqlalchemy import Base 

38 

39 

40# ============================================================================= 

41# DirtyTable 

42# ============================================================================= 

43 

44class DirtyTable(Base): 

45 """ 

46 Class to represent tables being modified during a client upload. 

47 """ 

48 __tablename__ = "_dirty_tables" 

49 

50 id = Column( 

51 # new in 2.1.0; ditch composite PK 

52 "id", Integer, primary_key=True, autoincrement=True 

53 ) 

54 device_id = Column( 

55 "device_id", Integer, 

56 ForeignKey(Device.id), 

57 comment="Source tablet device ID" 

58 ) 

59 tablename = Column( 

60 "tablename", TableNameColType, 

61 comment="Table in the process of being preserved" 

62 )