sudo apt-get install python-mysqldb yum install mysql-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