Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- #
- # Motores de bases de datos:
- # MySQl, MariaDB, PostreSQL, SQLite (free software)
- # SQLServer Oracle
- # Python tiene una DB-API
- # sqlite es el único con soporte integrado en Python: import sqlite3
- """
- MySQL: mysql-connector-python, PyMySQL
- PostgreSQL: psycopg, pg8000
- SQLite: sqlite3
- SQL Server: pymssql, pyodbc
- Oracle: cx_Oracle
- """
- import sqlite3
- # Me conecto a una bbdd. Si no existe, la crea
- conn = sqlite3.connect("database.sqlite")
- # Para hacer consultas, necesito crear un cursor
- cursor = conn.cursor()
- nombre = input("Ingrese un nombre: ")
- edad = int(input("Ingrese la edad: "))
- cursor.executescript(f"INSERT INTO personas VALUES('{nombre}',{edad})")
- conn.commit()
- # ataque SQL Injection Borrado de tabla personas
- # >> Nombre: Ale',14); DELETE FROM personas; --
- # >> Edad: 1256
- #
- # INSERT INTO personas VALUES('Ale',14); DELETE FROM personas;--',1256)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement