-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrandom_data.py
executable file
·232 lines (206 loc) · 8.69 KB
/
random_data.py
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
#!/usr/bin/python
"""
Generates some random data for ASM
TODO: Make Owner use new scheme, randomise more elements.
"""
import random
MAX_OWNERS = 105
MAX_ANIMALS = 105
surnames = [ "Smith", "Jones", "Spencer", "Cusack", "Tetley", "Cole",
"Adams", "Speed", "Swift", "Davison", "Neal", "Rawson",
"Wilson", "Hargan", "Cooper", "Felcher", "Belcher", "James",
"Jowitt", "Webb", "Churchill", "Johnson", "Jameson", "Espie",
"Barker", "Brutnell", "Edley", "Ager", "Cole", "Henshaw",
"Szeto", "Whitaker", "Murray" ]
addresses = [ "Mendip", "Central", "Whitehill" ]
roads = [ "Street", "Road", "Drive", "Rise", "Close", "Crescent" ]
titles = [ "Mr", "Mrs" ]
maleforenames = [ "James", "John", "Robert", "Jonathan", "Andrew" ,
"Charles", "Simon", "Alan", "Lee", "Ian", "Neil", "Anthony",
"Barry", "Jacob", "Mark", "Mathew", "Glen", "Glyn", "Peter" ]
femaleforenames = [ "Pauline", "Polly", "Patricia", "Kylie", "Ebony",
"Keeley", "Stacey", "Tracey", "Brigid", "Helen", "Mary",
"Anna", "Sophie", "Joanne" ]
animalnames = [ "Benji", "Zak", "Dexter", "Snoop", "Romeo", "Boo",
"Lynx", "Murdoch", "Gambon", "Sniff", "Squidge", "Socks",
"Buttons", "Freak", "Mclovin", "Thing", "Frankie", "Steve",
"Jaws", "Damien", "Tyson", "Jake", "Max", "Momma", "Fog",
"Shaguar", "Percy" ]
locations = [ "Dog Block 1", "Little Block", "Isolation Block", "Dog Block 2",
"Cattery", "Case Block" ]
# IDs
next_location = 10
next_owner = 1000
next_animal = 1000
def make_sql(table, bits):
s = "INSERT INTO %s (" % table
cols = ""
for i in bits:
if cols != "": cols += ", "
cols += i[0]
vals = ""
for i in bits:
if vals != "": vals += ", "
vals += i[1] % i[2]
return s + cols + ") VALUES (" + vals + ");"
def today_sql():
return "2009-02-27"
def random_date():
return "%0.4d-%0.2d-%0.2d" % ( random.randint(2001, 2008), random.randint(1, 12), random.randint(1, 28) )
def add_location(name, next_location):
print "INSERT INTO internallocation (ID, LocationName, LocationDescription) VALUES (%d, '%s', '')" % (next_location, name)
next_location += 1
return next_location
def add_owner(next_owner):
title = random.choice(titles)
if title == "Mr":
forenames = random.choice(maleforenames)
else:
forenames = random.choice(femaleforenames)
initials = forenames[0]
surname = random.choice(surnames)
name = "%s %s %s" % (title, forenames, surname)
address = "%d %s %s" % ( random.randint(1, 500), random.choice(addresses), random.choice(roads) )
bits = (
( "ID", "%d", next_owner ),
( "OwnerTitle", "'%s'", title ),
( "OwnerInitials", "'%s'", initials ),
( "OwnerForeNames", "'%s'", forenames ),
( "OwnerSurname", "'%s'", surname ),
( "OwnerName", "'%s'", name ),
( "OwnerAddress", "'%s'", address ),
( "OwnerTown", "'%s'", "Demo Town" ),
( "OwnerCounty", "'%s'", "Demoshire" ),
( "OwnerPostcode", "'%s'", "D1 EM0" ),
( "HomeTelephone", "'%s'", "03489 398983" ),
( "WorkTelephone", "'%s'", "02389 928932" ),
( "MobileTelephone", "'%s'", "07893 398433" ),
( "EmailAddress", "'%s'", "[email protected]" ),
( "IDCheck", "%d", 0 ),
( "Comments", "'%s'", "" ),
( "IsBanned", "%d", 0 ),
( "IsVolunteer", "%d", 0 ),
( "IsHomeChecker", "%d", 0 ),
( "IsMember", "%d", 0 ),
( "MembershipExpiryDate", "%s", "null" ),
( "IsDonor", "%d", 0 ),
( "IsShelter", "%d", 0 ),
( "IsACO", "%d", 0 ),
( "IsStaff", "%d", 0 ),
( "IsFosterer", "%d", 0 ),
( "IsRetailer", "%d", 0 ),
( "IsVet", "%d", 0 ),
( "HomeCheckAreas", "'%s'", "" ),
( "DateLastHomeChecked", "%s", "null" ),
( "DatePerformedLastHomeCheck", "%s", "null" ),
( "MatchActive", "%d", 0 ),
( "MatchSex", "%d", 0 ),
( "MatchSize", "%d", 0 ),
( "MatchAgeFrom", "%d", 0 ),
( "MatchAgeTo", "%d", 0 ),
( "MatchSpecies", "%d", 0 ),
( "MatchBreed", "%d", 0 ),
( "MatchGoodWithCats", "%d", 0 ),
( "MatchGoodWithDogs", "%d", 0 ),
( "MatchGoodWithChildren", "%d", 0 ),
( "MatchHouseTrained", "%d", 0 ),
( "MatchCommentsContain", "'%s'", "" ),
( "RecordVersion", "%d", 0 ),
( "CreatedBy", "'%s'", "random" ),
( "CreatedDate", "'%s'", today_sql() ),
( "LastChangedBy", "'%s'", "random" ),
( "LastChangedDate", "'%s'", today_sql() )
)
print make_sql("owner", bits)
next_owner += 1
return next_owner
def add_animal(next_animal):
bits = (
( "ID", "%d", next_animal ),
( "AnimalTypeID", "%d", random.randint(1, 2) ),
( "AnimalName", "'%s'", random.choice(animalnames) ),
( "NonShelterAnimal", "%d", 0 ),
( "BaseColourID", "%d", 1 ),
( "SpeciesID", "%d", 1 ),
( "BreedID", "%d", random.randint(1, 220) ),
( "Markings", "'%s'", "" ),
( "ShelterCode", "'%s'", str(next_animal) ),
( "ShortCode", "'%s'", str(next_animal) ),
( "UniqueCodeID", "%d", next_animal ),
( "YearCodeID", "%d", next_animal ),
( "AcceptanceNumber", "'%s'", ""),
( "DateOfBirth", "'%s'", random_date() ),
( "DeceasedDate", "%s", "null" ),
( "DiedOffShelter", "%d", 0 ),
( "Sex", "%d", random.randint(0, 1) ),
( "Size", "%d", random.randint(0, 3) ),
( "ShelterLocation", "%d", random.randint(10, 15) ),
( "Identichipped", "%d", 0 ),
( "IdentichipNumber", "'%s'", "" ),
( "IdentichipDate", "%s", "null" ),
( "Tattoo", "%d", 0 ),
( "TattooNumber", "'%s'", "" ),
( "TattooDate", "%s", "null" ),
( "Neutered", "%d", 1 ),
( "NeuteredDate", "%s", "null" ),
( "CombiTested", "%d", 0 ),
( "CombiTestResult", "%d", 0 ),
( "HeartwormTested", "%d", 0 ),
( "HeartwormTestDate", "%s", "null" ),
( "HeartwormTestResult", "%d", 0 ),
( "FLVResult", "%d", 0 ),
( "Declawed", "%d", 0 ),
( "HiddenAnimalDetails", "'%s'", "" ),
( "AnimalComments", "'%s'", "" ),
( "OwnersVetID", "%d", 0 ),
( "OriginalOwnerID", "%d", random.randint(1000, 1100) ),
( "BroughtInByOwnerID", "%d", random.randint(1000, 1100) ),
( "ReasonForEntry", "'%s'", "" ),
( "ReasonNO", "'%s'", "" ),
( "AmountDonatedOnEntry", "%d", 0 ),
( "DateBroughtIn", "'%s'", random_date() ),
( "EntryReasonID", "%d", 1 ),
( "HealthProblems", "'%s'", "" ),
( "PutToSleep", "%d", 0 ),
( "PTSReason", "'%s'", "" ),
( "PTSReasonID", "%d", 0 ),
( "IsDOA", "%d", 0 ),
( "IsTransfer", "%d", 0 ),
( "IsGoodWithCats", "%d", 0 ),
( "IsGoodWithDogs", "%d", 0 ),
( "IsGoodWithChildren", "%d", 0 ),
( "IsHouseTrained", "%d", 0 ),
( "IsNotAvailableForAdoption", "%d", 0 ),
( "HasSpecialNeeds", "%d", 0 ),
( "RabiesTag", "%s", "null" ),
( "Archived", "%d", 0 ),
( "ActiveMovementID", "%d", 0 ),
( "ActiveMovementType", "%s", "null" ),
( "ActiveMovementDate", "%s", "null" ),
( "ActiveMovementReturn", "%s", "null" ),
( "HasActiveReserve", "%d", 0 ),
( "MostRecentEntryDate", "'%s'", random_date() ),
( "TimeOnShelter", "'%s'", "" ),
( "AnimalAge", "'%s'", "" ),
( "RecordVersion", "%d", 0 ),
( "CreatedBy", "'%s'", "random" ),
( "CreatedDate", "'%s'", today_sql() ),
( "LastChangedBy", "'%s'", "random" ),
( "LastChangedDate", "'%s'", today_sql() )
)
print make_sql("animal", bits)
next_animal += 1
return next_animal
# Remove existing stuff
print "DELETE FROM internallocation WHERE ID >= 10;"
print "DELETE FROM animal WHERE ID >= 1000;"
print "DELETE FROM owner WHERE ID >= 1000;"
# Create some internal locations
for l in locations:
next_location = add_location(l, next_location)
# Create some owners
for i in range(0, MAX_OWNERS):
next_owner = add_owner(next_owner)
# Create some animals
for i in range(0, MAX_ANIMALS):
next_animal = add_animal(next_animal)