-
Notifications
You must be signed in to change notification settings - Fork 1
/
multiple_db_insertar_num_catalog.py
270 lines (259 loc) · 9.92 KB
/
multiple_db_insertar_num_catalog.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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
# -*- encoding: utf-8 -*-
import psycopg2
databases = ['granitoslalin',
'rocasmaresgra',
'granitosdelval',
'pizarrasdequiroga',
'penido',
'villarbacu',
'sanclodio',
'pizarrasuniversal',
'carucedo',
'aridosastariz',
'filloy',
'caborcooscuro',
'proinor',
'cuficadoscampos',
'cufica',
'graexcom',
'fidelgomez',
'dragadosdelmar',
'casayo',
'aplistone',
'intradima',
'pedrina',
'graniorega',
'leymon',
'trescunados',
'argel',
'carloslopezamil']
for db in databases:
connection = psycopg2.connect(database=db)
connection.set_isolation_level(0)
cr = connection.cursor()
cr.execute("""SELECT
pp.name_template
FROM
product_product pp
ORDER BY pp.name_template""")
records = cr.fetchall()
for record in records:
product_name_template = record[0]
modificar = 0
if ("POLVORA" in product_name_template) or \
("polvora" in product_name_template) or \
("pólvora" in product_name_template) or \
("RIOPOL" in product_name_template):
num_catalog = 37
modificar = 1
elif ("AMONITA" in product_name_template):
num_catalog = 12
modificar = 1
elif ("CORDTEX" in product_name_template):
num_catalog = 1224
modificar = 1
elif ("RIODET IZ" in product_name_template):
num_catalog = 166
modificar = 1
elif ("RIODET" in product_name_template) or \
("Riodet" in product_name_template) or \
("riodet" in product_name_template) or \
("RIODET IM" in product_name_template):
num_catalog = 168
modificar = 1
elif ("Daveydet" in product_name_template):
num_catalog = 216
modificar = 1
elif ("DAVEYNEL LP" in product_name_template):
num_catalog = 1144
modificar = 1
elif ("Daveynel SP" in product_name_template):
num_catalog = 1145
modificar = 1
elif ("daveynel" in product_name_template) or \
("Daveynel" in product_name_template) or \
("DAVEYNEL" in product_name_template):
num_catalog = 229
modificar = 1
elif ("DET.ORDINARIO" in product_name_template) or \
("DETONADOR" in product_name_template) or \
("DETONADORES" in product_name_template) or \
("detonadores" in product_name_template):
num_catalog = 184
modificar = 1
elif ("ergodyn" in product_name_template) or \
("ERGODYN" in product_name_template) or \
("Eegodyn" in product_name_template):
num_catalog = 1233
modificar = 1
elif ("EURODYN" in product_name_template):
num_catalog = 1043
modificar = 1
elif ("EXAN" in product_name_template):
num_catalog = 1196
modificar = 1
elif ("mecha lenta" in product_name_template) or \
("MECHA LENTA" in product_name_template):
num_catalog = 68
modificar = 1
elif ("NITRAM" in product_name_template):
num_catalog = 1091
modificar = 1
elif ("Pax" in product_name_template):
num_catalog = 271
modificar = 1
elif ("RELES" in product_name_template):
num_catalog = 67
modificar = 1
elif ("RIOCORD 100" in product_name_template) or \
("100 GR. Riocord" in product_name_template):
num_catalog = 1065
modificar = 1
elif ("RIOCORD 80" in product_name_template) or \
("80 GR. Riocord" in product_name_template):
num_catalog = 1064
modificar = 1
elif ("RIOCORD 40" in product_name_template):
num_catalog = 1063
modificar = 1
elif ("RIOCORD 20" in product_name_template):
num_catalog = 1062
modificar = 1
elif ("RIOCORD 15" in product_name_template):
num_catalog = 1061
modificar = 1
elif ("RIOCORD 12" in product_name_template) or \
("12 GR. Riocord" in product_name_template):
num_catalog = 1060
modificar = 1
elif ("RIOCORD RF 10" in product_name_template) or \
("RIOCORD 10 GRS. REFORZADO" in product_name_template):
num_catalog = 1059
modificar = 1
elif ("RIOCORD 10" in product_name_template):
num_catalog = 1058
modificar = 1
elif ("RIOCORD RF 6" in product_name_template) or \
("RIOCORD 6 G. REF" in product_name_template) or \
("RIOCORD 6 GRS. REFORZADO" in product_name_template):
num_catalog = 1057
modificar = 1
elif ("RIOCORD 6" in product_name_template) or \
("6 GR. Riocord" in product_name_template):
num_catalog = 1056
modificar = 1
elif ("RIOCORD 3" in product_name_template):
num_catalog = 1112
modificar = 1
elif ("RIOMEX" in product_name_template):
num_catalog = 1276
modificar = 1
elif ("RIOPER G" in product_name_template):
num_catalog = 6
modificar = 1
elif ("RIOPER P" in product_name_template):
num_catalog = 8
modificar = 1
elif ("UNITRONIC" in product_name_template):
num_catalog = 1246
modificar = 1
elif ("RIODIN" in product_name_template) or \
("Riodin" in product_name_template):
num_catalog = 10
modificar = 1
elif ("RIOGEL" in product_name_template) or \
("Riogel" in product_name_template):
num_catalog = 1
modificar = 1
elif ("RIONEL SCX" in product_name_template) or \
("Rionel SCX" in product_name_template) or \
("Rionel LLX" in product_name_template) or \
("RIONEL LLX" in product_name_template) or \
("Primadet EZTL" in product_name_template) or \
("PRIMADET EZTL" in product_name_template) or \
("Primadet EZTL" in product_name_template) or \
("EZTL/Rionel SCX" in product_name_template) or \
("EZTL/RIONEL SCX" in product_name_template):
num_catalog = 1001
modificar = 1
elif ("RIONEL MS" in product_name_template) or \
("RIONEL MS" in product_name_template) or \
("Rionel MS" in product_name_template) or \
("PRIMADET MS" in product_name_template) or \
("primadet Ms" in product_name_template) or \
("Primadet/Rionel MS" in product_name_template) or \
("PRIMADET/RIONEL MS" in product_name_template):
num_catalog = 1002
modificar = 1
elif ("RIONEL LP" in product_name_template) or \
("RIONEL LP" in product_name_template) or \
("Rionel LP" in product_name_template) or \
("PRIMADET/ RIONEL LP" in product_name_template):
num_catalog = 1003
modificar = 1
elif ("RIONEL DDX" in product_name_template) or \
("Rionel DDX" in product_name_template) or \
("PRIMADET EZDET" in product_name_template) or \
("Primadet EZDET" in product_name_template) or \
("Primadet EZ" in product_name_template) or \
("Primadet EZ" in product_name_template):
num_catalog = 1004
modificar = 1
elif ("RIONEL BC" in product_name_template) or \
("Rionel BC" in product_name_template):
num_catalog = 1141
modificar = 1
elif ("RIONEL S" in product_name_template) or \
("Rionel S" in product_name_template) or \
("Primadet S" in product_name_template) or \
("PRIMADET S" in product_name_template):
num_catalog = 1157
modificar = 1
elif ("RIONEL SCE" in product_name_template) or \
("Rionel SCE" in product_name_template):
num_catalog = 1280
modificar = 1
elif ("RIONEL UG" in product_name_template) or \
("Rionel UG" in product_name_template):
num_catalog = 1281
modificar = 1
elif ("RIONEL DDE" in product_name_template) or \
("Rionel DDE" in product_name_template):
num_catalog = 1282
modificar = 1
elif ("RIOXAM" in product_name_template) or \
("NAGOLITA" in product_name_template):
num_catalog = 5
modificar = 1
elif ("SEICORD" in product_name_template):
num_catalog = 1199
modificar = 1
elif ("ALNAFO" in product_name_template):
num_catalog = 2
modificar = 1
elif ("BOOSTER" in product_name_template):
num_catalog = 1116
modificar = 1
elif ("DAVEYCORD 70" in product_name_template):
num_catalog = 250
modificar = 1
elif ("DAVEYCORD 40" in product_name_template):
num_catalog = 249
modificar = 1
elif ("DAVEYCORD 20" in product_name_template):
num_catalog = 248
modificar = 1
elif ("DAVEYCORD 15" in product_name_template):
num_catalog = 247
modificar = 1
elif ("DAVEYCORD 10" in product_name_template):
num_catalog = 246
modificar = 1
elif ("DAVEYCORD 5" in product_name_template):
num_catalog = 245
modificar = 1
if modificar == 1:
cr.execute("""UPDATE product_product SET num_catalog = %s
WHERE name_template = %s""",(num_catalog, product_name_template))
connection.commit
connection.close()