Hello, please sign in or register
You are here: Home

Setting up a ADOdb connection to MySQL in Python

Preface

Python named after "Monty Pythons Flying Circus".... and if that doesn't make programmers look coool then undoubable nowt will.

I started using Python Yesturday... and like learning any new language you often only learn what you think it cant do first and then unlearn those as you go along. One thing it can do is interact with mysql. .... -> Here's how

Install python-mysql

Download from anywhere i got it from http://sourceforge.net/projects/mysql-python

Prerequisites

I'm running Fedora Core and it had most of what i needed, i updated gcc yum install gcc and ran the code below.

tar xfz MySQL-python-1.2.0.tar.gz
cd MySQL-python-1.2.0
python setup.py build
su # or use sudo
python setup.py install

I got a few errors out of this .... but hey presto it still works ( touch my veneer desk )

Including adodb should now be instinctive.

Make a Database connection

import adodb  
 
conn = adodb.NewADOConnection('mysql')  
conn.Connect('localhost','root','','books')  
cursor = conn.Execute('select * from bc')  
while not cursor.EOF:  	
    print cursor.fields  	
    cursor.MoveNext()  
cursor.Close()

 

Comments

guoyanying
But the replica watches sentry reebok shoes knew abercrombie and fitch uk his
Created 07/10/15
1015maoqiuyun
coach outlet online, http://www.coachoutletonline-store.us.com/
Created 15/10/15
michael kors factory outlet
adidas nmd pandora bracelet
Created 16/05/17
Title*
Comment

Prove you are not a robot

To prove you are not a robot, please type in the six character code you see in the picture below
Security confirmation codeI can't see this!
Contact
Name*
Email never shown*
Home Page

Author

Andrew Dodson
Since:Feb 2007

Comment | flag

Categories

Bookmark and Share