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
http://debian.sreenadh.in/2008/11/28/how-to-enable-designer-in-phpmyadmin/


Now you can setup python for apache2:

http://www.howtoforge.com/embedding-python-in-apache2-with-mod_python-debian-etch



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
#!/usr/bin/python

import MySQLdb

# enable debugging
import cgitb
cgitb.enable()

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

print "Hello World!"

# connect
mydb = MySQLdb.connect(host="127.0.0.1", user="root", passwd="root",
db="tdb")

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];

agonzalez@kozlex:~/django-dev$



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 en la entrada