jueves, 21 de noviembre de 2013

phpmyadmin on ubuntu connecting to mysql by phyton

Just follow these links and few more steps:

Then enable design view, this is really useful

Now you can setup python for apache2:


don't forget to install python-mysqldb

apt-get install python-mysqldb

restart apache:

/etc/init.d/apache2 restart

Now let's try a small db connection:

agonzalez@kozlex:~/django-dev$ cat /var/www/test4.py

import MySQLdb

# enable debugging
import cgitb

print "Content-Type: text/plain;charset=utf-8"

print "Hello World!"

# connect
mydb = MySQLdb.connect(host="", user="root", passwd="root",

cursor = mydb.cursor()

# execute SQL select statement
cursor.execute("SELECT * FROM test")

# get the number of rows in the resultset
numrows = int(cursor.rowcount)

# get and display one row at a time.
for x in range(0,numrows):
    row = cursor.fetchone()
    print (row[0], "-->", row[1])

def index(req):
  return row[1];


That should work although the prints are not shown!

P.D.  Libya flag is the only country flag with single color and no design.

No hay comentarios:

Publicar un comentario