-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcarga_datos.py
191 lines (164 loc) · 6.1 KB
/
carga_datos.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
import sqlite3
# establecer la concexión
conexion = sqlite3.connect("db.sqlite3")
# crear un cursor para realizar la consulta
consulta = conexion.cursor()
# crear un cursor para realizar la consulta
consulta = conexion.cursor()
# insertar datos en una tabla BARRIOS
reg1 = ("SAN CAYETANO","")
reg2 = ("BELGRANO","")
reg3 = ("LA MADRID","")
reg4 = ("MITRE","")
reg5 = ("SAN ANTONIO","")
reg6 = ("SAN MARTIN","")
sql = "INSERT INTO app_campaing_barrio(nombre,detalle) VALUES(?,?)"
err = False
try:
consulta.execute(sql,reg1)
consulta.execute(sql,reg2)
consulta.execute(sql,reg3)
consulta.execute(sql,reg4)
consulta.execute(sql,reg5)
consulta.execute(sql,reg6)
except :
err = True
conexion.rollback()
if not err:
conexion.commit()
print("BARRIOS REGISTRADOS!")
else:
conexion.rollback()
print("NO SE PUDIERON REGISTRAR LOS DATOS BARRIO!")
# insertar datos en una tabla LUGARES
reg1 = ("ESCUELA 506","CALLE 10 N 123")
reg2 = ("ESCUELA 31","CALLE 12 E 9")
reg3 = ("ESCUELA 252","CALLE 23 E 86 Y 8")
sql = "INSERT INTO app_campaing_lugar(nombre,direccion) VALUES(?,?)"
err = False
try:
consulta.execute(sql,reg1)
consulta.execute(sql,reg2)
consulta.execute(sql,reg3)
except :
err = True
conexion.rollback()
if not err:
conexion.commit()
print("LUGARES REGISTRADOS!")
else:
conexion.rollback()
print("NO SE PUDIERON REGISTRAR LOS DATOS LUGARES!")
# insertar datos en una tabla CAMPAING
reg1 = ('10/01/2017',150,2000,2000,"www.amoalosperros.com/campaing/1",1,"CASTRACION",False,False)
reg2 = ('10/02/2017',160,3000,3000,"www.amoalosperros.com/campaing/2",4,"CASTRACION",False,False)
reg3 = ('10/03/2017',170,2000,2000,"www.amoalosperros.com/campaing/3",2,"CASTRACION",False,False)
reg4 = ('10/04/2017',180,4000,4000,"www.amoalosperros.com/campaing/4",3,"CASTRACION",False,False)
reg5 = ('10/05/2017',190,3000,3000,"www.amoalosperros.com/campaing/5",1,"CASTRACION",False,False)
reg6 = ('10/06/2017',200,2000,2000,"www.amoalosperros.com/campaing/6",4,"CASTRACION",False,False)
sql = "INSERT INTO app_campaing_campaing(fecha,monto_valor_operacion,monto_inter_grupo_gastado,monto_inter_grupo_total,url,lugar_id,tipo,preinscripcion,habilitada) VALUES(?,?,?,?,?,?,?,?,?)"
err = False
try:
consulta.execute(sql,reg1)
consulta.execute(sql,reg2)
consulta.execute(sql,reg3)
consulta.execute(sql,reg4)
consulta.execute(sql,reg5)
consulta.execute(sql,reg6)
except :
err = True
conexion.rollback()
if not err:
conexion.commit()
print("CAMPAING REGISTRADOS!")
else:
conexion.rollback()
print("NO SE PUDIERON REGISTRAR LOS DATOS CAMPAING!")
# insertar datos en una tabla PROPIETARIOS
reg1 = ("RAMON","VALDEZ",12809233,4433551,1)
reg2 = ("RAUL","GOMEZ",31890123,4433552,2)
reg3 = ("ALEJANDRA","PERREN",23123123,4433553,3)
reg4 = ("MARIA","PEREZ",11333221,4433554,1)
reg5 = ("LAURA","PEREZ",16087123,4433555,2)
reg6 = ("MARGARITA","ORTEGA",21999123,4433556,2)
sql = "INSERT INTO app_campaing_propietario(nombre,apellido,dni,telefono,barrio_id) VALUES(?,?,?,?,?)"
err = False
try:
consulta.execute(sql,reg1)
consulta.execute(sql,reg2)
consulta.execute(sql,reg3)
consulta.execute(sql,reg4)
consulta.execute(sql,reg5)
consulta.execute(sql,reg6)
except :
err = True
conexion.rollback()
if not err:
conexion.commit()
print("PROPIETARIOS REGISTRADOS!")
else:
conexion.rollback()
print("NO SE PUDIERON REGISTRAR LOS DATOS PROPIETARIO!")
# insertar datos en una tabla ANIMALITOS
reg1 = ("PERRITO 1","DESCRIPCION","CANINO","MACHO",1,1,200,"JUAN",1,1)
reg2 = ("PERRITO 2","DESCRIPCION","CANINO","MACHO",2,2,200,"JUAN",1,2)
reg3 = ("PERRITO 3","DESCRIPCION","CANINO","MACHO",3,3,200,"JUAN",1,3)
reg4 = ("PERRITA 4","DESCRIPCION","CANINO","HEMBRA",4,4,200,"JUAN",1,1)
reg5 = ("PERRITA 5","DESCRIPCION","CANINO","HEMBRA",5,5,200,"JUAN",1,2)
reg6 = ("PERRITA 6","DESCRIPCION","CANINO","HEMBRA",6,6,200,"JUAN",1,4)
reg7 = ("GATITO 7","DESCRIPCION","FELINO","MACHO",1,1,200,"JUAN",1,1)
reg8 = ("GATITO 2","DESCRIPCION","FELINO","MACHO",2,2,200,"JUAN",1,5)
reg9 = ("GATITO 3","DESCRIPCION","FELINO","MACHO",3,3,200,"JUAN",1,5)
reg10 =("GATITA 4","DESCRIPCION","FELINO","HEMBRA",4,4,200,"JUAN",1,6)
reg11= ("GATITA 5","DESCRIPCION","FELINO","HEMBRA",5,5,200,"JUAN",1,3)
reg12 =("GATITA 6","DESCRIPCION","FELINO","HEMBRA",6,6,200,"JUAN",1,2)
reg13 = ("PERRITO 1","DESCRIPCION","CANINO","MACHO",1,1,200,"JUAN",2,1)
reg14 = ("PERRITO 2","DESCRIPCION","CANINO","MACHO",2,2,200,"JUAN",2,2)
reg15 = ("PERRITO 3","DESCRIPCION","CANINO","MACHO",3,3,200,"JUAN",2,3)
reg16 = ("PERRITA 4","DESCRIPCION","CANINO","HEMBRA",4,4,200,"JUAN",2,1)
reg17 = ("PERRITA 5","DESCRIPCION","CANINO","HEMBRA",5,5,200,"JUAN",2,2)
reg18 = ("PERRITA 6","DESCRIPCION","CANINO","HEMBRA",6,6,200,"JUAN",2,4)
reg19 = ("GATITO 7","DESCRIPCION","FELINO","MACHO",1,1,200,"JUAN",2,1)
reg20 = ("GATITO 2","DESCRIPCION","FELINO","MACHO",2,2,200,"JUAN",2,5)
reg21 = ("GATITO 3","DESCRIPCION","FELINO","MACHO",3,3,200,"JUAN",2,5)
reg22 =("GATITA 4","DESCRIPCION","FELINO","HEMBRA",4,4,200,"JUAN",2,6)
reg23= ("GATITA 5","DESCRIPCION","FELINO","HEMBRA",5,5,200,"JUAN",2,3)
reg24 =("GATITA 6","DESCRIPCION","FELINO","HEMBRA",6,6,200,"JUAN",2,2)
sql = "INSERT INTO app_campaing_animalito(nombre_mascota,descripcion,especie,sexo,nro_pre_inscripcion,turno,abono,user_name,campaing_id,propietario_id) VALUES(?,?,?,?,?,?,?,?,?,?)"
err = False
try:
consulta.execute(sql,reg1)
consulta.execute(sql,reg2)
consulta.execute(sql,reg3)
consulta.execute(sql,reg4)
consulta.execute(sql,reg5)
consulta.execute(sql,reg6)
consulta.execute(sql,reg7)
consulta.execute(sql,reg8)
consulta.execute(sql,reg9)
consulta.execute(sql,reg10)
consulta.execute(sql,reg11)
consulta.execute(sql,reg12)
consulta.execute(sql,reg13)
consulta.execute(sql,reg14)
consulta.execute(sql,reg15)
consulta.execute(sql,reg16)
consulta.execute(sql,reg17)
consulta.execute(sql,reg18)
consulta.execute(sql,reg19)
consulta.execute(sql,reg20)
consulta.execute(sql,reg21)
consulta.execute(sql,reg22)
consulta.execute(sql,reg23)
consulta.execute(sql,reg24)
except :
err = True
conexion.rollback()
if not err:
conexion.commit()
print("ANIMALITOS REGISTRADOS!")
else:
conexion.rollback()
print("NO SE PUDIERON REGISTRAR LOS DATOS ANIMALITOS!")
consulta.close()
conexion.close()