bbdd-utils 0.3.12__py3-none-any.whl → 0.3.13__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
bbdd_utils/utils.py CHANGED
@@ -74,7 +74,6 @@ def Insert(conn, tabla, data):
74
74
  if isinstance(conn, sqlite3.Connection):
75
75
  print("Conexión exitosa a la base de datos SQL.")
76
76
  cursor = conn.cursor()
77
-
78
77
  # Crear la tabla dinámicamente si no existe
79
78
  columnas_definicion = ", ".join([f"{col} TEXT" for col in columnas])
80
79
  cursor.execute(f"""
@@ -85,20 +84,12 @@ def Insert(conn, tabla, data):
85
84
  """)
86
85
  print(f"Tabla '{tabla}' verificada o creada exitosamente.")
87
86
 
88
- # Si `data` es un solo diccionario, conviértelo en una lista
89
- if isinstance(data, dict):
90
- data = [data]
91
- if isinstance(data, tuple):
92
- data = list(data)
93
- # Inserta cada elemento de la lista en la tabla
94
- for registro in data:
95
- columnas = ", ".join(registro.keys())
96
- valores = ", ".join(["?"] * len(registro))
97
- query = f"INSERT INTO {tabla} ({columnas}) VALUES ({valores})"
98
- cursor.execute(query, tuple(registro.values()))
87
+ # Inserta datos en la tabla
88
+ placeholders = ", ".join(["?" for _ in columnas])
89
+ cursor.execute(f"INSERT INTO {tabla} ({', '.join(columnas)}) VALUES ({placeholders})", valores)
99
90
  conn.commit()
100
- print("Datos insertados correctamente en SQLite.")
101
-
91
+ print(f"Datos insertados correctamente en la tabla '{tabla}' de la base de datos SQL.")
92
+
102
93
  # Consulta los datos insertados
103
94
  cursor.execute("SELECT * FROM {tabla}")
104
95
  resultados = cursor.fetchall()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bbdd_utils
3
- Version: 0.3.12
3
+ Version: 0.3.13
4
4
  Summary: insertar datos en una base de datos SQL o NoSQL
5
5
  Author: Luis_J_Domingo
6
6
  Description-Content-Type: text/markdown
@@ -0,0 +1,7 @@
1
+ bbdd_utils/__init__.py,sha256=mjRX7GqWkOJq66KqghZ4MZE0Aai6R89LPeu1mjq4lD4,121
2
+ bbdd_utils/utils.py,sha256=eDco-IZrcw-vgzvAo6r9KMTrQ2YGC4IDRokR5A8yPjc,5244
3
+ bbdd_utils-0.3.13.dist-info/licenses/LICENSE,sha256=D4uqg6QX0fapLNcdUznOuGaRIUPnypOdeE2zIyYq7xY,217
4
+ bbdd_utils-0.3.13.dist-info/METADATA,sha256=oiJ2Lk6tBq-PWaC-ndrTJiHno-a8fCYFIqq-khqJAjI,694
5
+ bbdd_utils-0.3.13.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
6
+ bbdd_utils-0.3.13.dist-info/top_level.txt,sha256=bBGkVkxnOw7tZ2zRcyCM3lgVgYo1hFbcmwkGdKAj9Gk,11
7
+ bbdd_utils-0.3.13.dist-info/RECORD,,
@@ -1,7 +0,0 @@
1
- bbdd_utils/__init__.py,sha256=mjRX7GqWkOJq66KqghZ4MZE0Aai6R89LPeu1mjq4lD4,121
2
- bbdd_utils/utils.py,sha256=fofJN6Cm1GlKnBpgMA3j4UxGgUAX9Zbo3zaMJu7jpY8,5557
3
- bbdd_utils-0.3.12.dist-info/licenses/LICENSE,sha256=D4uqg6QX0fapLNcdUznOuGaRIUPnypOdeE2zIyYq7xY,217
4
- bbdd_utils-0.3.12.dist-info/METADATA,sha256=pQmlHxiHRVOt9nrvp5TQlE5qBoYRsaC9Te7jB7lFjzA,694
5
- bbdd_utils-0.3.12.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
6
- bbdd_utils-0.3.12.dist-info/top_level.txt,sha256=bBGkVkxnOw7tZ2zRcyCM3lgVgYo1hFbcmwkGdKAj9Gk,11
7
- bbdd_utils-0.3.12.dist-info/RECORD,,