-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode_for_shell.py
More file actions
51 lines (42 loc) · 1.81 KB
/
code_for_shell.py
File metadata and controls
51 lines (42 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
from backend.models import *
# Simple Insertion
# Requires the primary key or else will not function correctly.
# #
service1 = Service(servicecode='75469', servicename='UpDown Postal', description='The West Side packaging service.')
service2 = Service(servicecode='339988', servicename='JiDex Air', description='Some alternative postal service.')
service3 = Service(servicecode='556644', servicename='Xpress Inc', description='X means excellent!')
service1.save()
service2.save()
service3.save()
# Deleting Data
# Will delete service1.
# #
service1.delete()
# Updating Data and Updating Data with Queries
#
# This will add some rows to the Subscriber table but with missing keys. These keys
# can be updated manually or can be update by passing a query.
#
# Subscribers 'Andy' and 'Bree' will have an updated to aService Query.
# 'Cooral' will have update to the bService Query.
#
# Lastly, a manual update on 'Cooral' username.
#
# #
# Queries
aService = Service.objects.get(servicecode='339988')
bService = Service.objects.get(servicecode='556644')
# Initiated Rows
Andy = Subscriber(subscriberID='1001', username='Andy123', subscriptiontypecode='23', requestcode='1001', startdate='2015-04-12', enddate=None,beneficiaryID='85006341')
Bree = Subscriber(subscriberID='1002', username='xxBree90xx', subscriptiontypecode='65', requestcode='2003', startdate='2011-07-22', motifofcancellation='', beneficiaryID='90045577')
Cooral = Subscriber(subscriberID='3456', username='Deh_Cooral67', subscriptiontypecode='41', requestcode='8009', startdate='2016-09-06', enddate='2020-08-31', motifofcancellation='Did not carry the 1.')
# Update with queries
Andy.servicecode = str(aService)
Bree.servicecode = str(bService)
Cooral.servicecode = str(aService)
# Update Manually
Cooral.username = 'Cooral_l33T'
# Commits
Andy.save()
Bree.save()
Cooral.save()