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.

Read an ISO content on ubuntu

Has been a while since I don't add something here.. I've been working with PXE to overwrite an MBR and I found a small tip that I share now...


To install PXE is needed to install some files from alternate ubuntu, what I did is to get the iso, mount it and find what I need.


So..

To read an iso content on ubuntu:

# sudo mkdir /mnt/iso
# sudo mount -o loop -t iso9660 ubuntu-12.04.3-alternate-amd64.iso /mnt/iso


agonzalez@kozlex:/mnt/iso$ ls /mnt/iso/
boot  cdromupgrade  dists  doc  EFI  install  isolinux  md5sum.txt  pics  pool  preseed  README.diskdefines  ubuntu
agonzalez@kozlex:/mnt/iso$

Annnnd... there it is... I found what I need..

agonzalez@kozlex:/mnt/iso$ find . -name  pxelinux.0
./install/netboot/pxelinux.0
./install/netboot/ubuntu-installer/amd64/pxelinux.0
agonzalez@kozlex:/mnt/iso$



P.D. The vatican is also a country and its flag and is one of the two sqare flags in the world.