-
-
Save parzibyte/42af861dbd9b7a352c43bdb6924afde7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://parzibyte.me/blog | |
bd, err:= sql.Open("sqlite3", "mibd.bd") // Puede ser cualquier motor | |
if err != nil { | |
panic(err)// Manejar error como tú prefieras | |
} | |
defer bd.Close() | |
// Puede ser cualquier consulta | |
resultado, err := bd.Exec(`INSERT INTO personas(nombre) | |
VALUES | |
(?)`, "Luis") | |
if err != nil { | |
panic(err)// Manejar error como tú prefieras | |
} | |
ultimoId,err := resultado.LastInsertId() | |
if err != nil{ | |
panic(err)// Manejar error como tú prefieras | |
} | |
// Aquí ya tenemos a ultimoId, haz lo que quieras con él |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment