domingo, 28 de enero de 2018

python mysql

sudo apt-get install python-mysqldb
yum install mysql-python


#!/usr/bin/python
import MySQLdb

db = MySQLdb.connect(host="localhost",  # your host
                     user="root",       # username
                     passwd="1234",     # password
                     db="asterisk")   # name of the database

# Create a Cursor object to execute queries.
cur = db.cursor()

# Select data from table using SQL query.
cur.execute("SELECT * FROM cdr limit 3")

# print the first and second columns
for row in cur.fetchall() :

    print row

https://pythonspot.com/mysql-with-python/

No hay comentarios:

Publicar un comentario