<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="es">
	<id>http://wiki.cabal.mx/index.php?action=history&amp;feed=atom&amp;title=Curso_de_Programaci%C3%B3n_en_Python%2FMySQL-4</id>
	<title>Curso de Programación en Python/MySQL-4 - Historial de revisiones</title>
	<link rel="self" type="application/atom+xml" href="http://wiki.cabal.mx/index.php?action=history&amp;feed=atom&amp;title=Curso_de_Programaci%C3%B3n_en_Python%2FMySQL-4"/>
	<link rel="alternate" type="text/html" href="http://wiki.cabal.mx/index.php?title=Curso_de_Programaci%C3%B3n_en_Python/MySQL-4&amp;action=history"/>
	<updated>2026-05-21T21:13:44Z</updated>
	<subtitle>Historial de revisiones para esta página en el wiki</subtitle>
	<generator>MediaWiki 1.32.1</generator>
	<entry>
		<id>http://wiki.cabal.mx/index.php?title=Curso_de_Programaci%C3%B3n_en_Python/MySQL-4&amp;diff=121302&amp;oldid=prev</id>
		<title>Rrc en 21:57 12 mar 2016</title>
		<link rel="alternate" type="text/html" href="http://wiki.cabal.mx/index.php?title=Curso_de_Programaci%C3%B3n_en_Python/MySQL-4&amp;diff=121302&amp;oldid=prev"/>
		<updated>2016-03-12T21:57:44Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Página nueva&lt;/b&gt;&lt;/p&gt;&lt;div&gt;__NOTOC__&lt;br /&gt;
* [[:#MySQL-4 | MySQL-4.py]]&lt;br /&gt;
&lt;br /&gt;
== MySQL-4.py ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line=&amp;quot;GESHI_FANCY_LINE_NUMBERS&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#!/usr/bin/python3&lt;br /&gt;
#-*-coding: utf-8 -*-&lt;br /&gt;
&lt;br /&gt;
import mysql.connector&lt;br /&gt;
from mysql.connector import errorcode&lt;br /&gt;
&lt;br /&gt;
config = {&lt;br /&gt;
  &amp;#039;user&amp;#039;: &amp;#039;PythonClase&amp;#039;,&lt;br /&gt;
  &amp;#039;password&amp;#039;: &amp;#039;Py800se&amp;#039;,&lt;br /&gt;
  &amp;#039;host&amp;#039;: &amp;#039;127.0.0.1&amp;#039;,&lt;br /&gt;
  &amp;#039;database&amp;#039;: &amp;#039;PythonClase&amp;#039;,&lt;br /&gt;
  &amp;#039;raise_on_warnings&amp;#039;: True,&lt;br /&gt;
  &amp;#039;unix_socket&amp;#039;: &amp;#039;/var/lib/mysql/mysql.sock&amp;#039;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
  Conn = mysql.connector.connect(**config)&lt;br /&gt;
except mysql.connector.Error as err:&lt;br /&gt;
  if err.errno == errorcode.ER_ACCESS_DENIED_ERROR:&lt;br /&gt;
    print( &amp;quot;UsuarioNombre o Contraseña incorrecto&amp;quot; )&lt;br /&gt;
  elif err.errno == errorcode.ER_BAD_DB_ERROR:&lt;br /&gt;
    print( &amp;quot;Base de Datos no existe&amp;quot; )&lt;br /&gt;
  else:&lt;br /&gt;
    print( err )&lt;br /&gt;
&lt;br /&gt;
Cursor = Conn.cursor()   &lt;br /&gt;
&lt;br /&gt;
Query = &amp;quot;INSERT INTO TablaDePrueba values ( NULL, &amp;#039;Valor 1&amp;#039; )&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
Cursor.execute( Query )&lt;br /&gt;
&lt;br /&gt;
Conn.commit()&lt;br /&gt;
&lt;br /&gt;
Query = &amp;quot;INSERT INTO TablaDePrueba ( CampoDePueba ) values ( &amp;#039;Valor 2&amp;#039; )&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
Cursor.execute( Query )&lt;br /&gt;
&lt;br /&gt;
Conn.commit()&lt;br /&gt;
&lt;br /&gt;
Conn.close()&lt;br /&gt;
&lt;br /&gt;
print( &amp;quot;Mira en la TablaDePrueba a ver los registros nuevos&amp;quot; )&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Resultado ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[rrc@Pridd PythonClase]$ mysql -u PythonClase -pPy800se&lt;br /&gt;
Welcome to the MariaDB monitor.  Commands end with ; or \g.&lt;br /&gt;
Your MariaDB connection id is 27&lt;br /&gt;
Server version: 10.0.22-MariaDB Mageia MariaDB Server&lt;br /&gt;
&lt;br /&gt;
Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.&lt;br /&gt;
&lt;br /&gt;
Type &amp;#039;help;&amp;#039; or &amp;#039;\h&amp;#039; for help. Type &amp;#039;\c&amp;#039; to clear the current input statement.&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; use PythonClase&lt;br /&gt;
Database changed&lt;br /&gt;
MariaDB [PythonClase]&amp;gt; select * from TablaDePrueba;&lt;br /&gt;
+----+--------------+&lt;br /&gt;
| id | CampoDePueba |&lt;br /&gt;
+----+--------------+&lt;br /&gt;
|  1 | Valor 1      |&lt;br /&gt;
|  2 | Valor 2      |&lt;br /&gt;
+----+--------------+&lt;br /&gt;
1 row in set (0.00 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [PythonClase]&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rrc</name></author>
		
	</entry>
</feed>