Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Using python with MySQL

Reply
Thread Tools

Using python with MySQL

 
 
HMS Surprise
Guest
Posts: n/a
 
      05-01-2007

Greetings,

I need to peform some simple queries via MySQL. Searching the list I
see that folks are accessing it with python. I am very new to python
and pretty new to MySQL too. Would appreciate it if you could point me
to some documentation for accessing MySQL via python. Something of the
"Python and MySQL for Dummies" caliber would be about my speed, but of
course I will be thankful for anything offered.

Thanks,

jvh

 
Reply With Quote
 
 
 
 
Greg Donald
Guest
Posts: n/a
 
      05-01-2007
On 1 May 2007 12:40:20 -0700, HMS Surprise <(E-Mail Removed)> wrote:
> I need to peform some simple queries via MySQL. Searching the list I
> see that folks are accessing it with python. I am very new to python
> and pretty new to MySQL too. Would appreciate it if you could point me
> to some documentation for accessing MySQL via python. Something of the
> "Python and MySQL for Dummies" caliber would be about my speed, but of
> course I will be thankful for anything offered.



http://mysql-python.sourceforge.net/



--
Greg Donald
http://destiney.com/
 
Reply With Quote
 
 
 
 
Shafik
Guest
Posts: n/a
 
      05-01-2007
On May 1, 10:40 pm, HMS Surprise <(E-Mail Removed)> wrote:
> Greetings,
>
> I need to peform some simple queries via MySQL. Searching the list I
> see that folks are accessing it with python. I am very new to python
> and pretty new to MySQL too. Would appreciate it if you could point me
> to some documentation for accessing MySQL via python. Something of the
> "Python and MySQL for Dummies" caliber would be about my speed, but of
> course I will be thankful for anything offered.
>
> Thanks,
>
> jvh


hi,
download this module:
http://sourceforge.net/projects/mysql-python
and look at the tutorial here:
http://www.kitebird.com/articles/pydbapi.html

 
Reply With Quote
 
HMS Surprise
Guest
Posts: n/a
 
      05-01-2007
On May 1, 2:58 pm, "Greg Donald" <(E-Mail Removed)> wrote:
> On 1 May 2007 12:40:20 -0700, HMS Surprise <(E-Mail Removed)> wrote:
>
> > I need to peform some simple queries via MySQL. Searching the list I
> > see that folks are accessing it with python. I am very new to python
> > and pretty new to MySQL too. Would appreciate it if you could point me
> > to some documentation for accessing MySQL via python. Something of the
> > "Python and MySQL for Dummies" caliber would be about my speed, but of
> > course I will be thankful for anything offered.

>
> http://mysql-python.sourceforge.net/
>
> --
> Greg Donaldhttp://destiney.com/



Most excellent!

Many thanks, Greg. I'll get started reading pronto.


jvh

 
Reply With Quote
 
HMS Surprise
Guest
Posts: n/a
 
      05-01-2007

> hi,
> download this module:http://sourceforge.net/projects/mysql-python
> and look at the tutorial here:http://www.kitebird.com/articles/pydbapi.html


Done, thank you too.

jh

 
Reply With Quote
 
hlubenow
Guest
Posts: n/a
 
      05-03-2007
HMS Surprise wrote:

> Greetings,
>
> I need to peform some simple queries via MySQL. Searching the list I
> see that folks are accessing it with python. I am very new to python
> and pretty new to MySQL too. Would appreciate it if you could point me
> to some documentation for accessing MySQL via python. Something of the
> "Python and MySQL for Dummies" caliber would be about my speed, but of
> course I will be thankful for anything offered.
>
> Thanks,
>
> jvh


There's even another approach:
If you're on Linux, Qt3 may be available. Install its Python-bindings. Given
a database "MyDatabase", with password "MyPassword" for user "root" and
inside the database a table "MyTable", you can then do something like this:

----------------------------------------------------
#!/usr/bin/env python

from qt import *
import sys
from qtsql import QSqlDatabase, QSqlQuery

app = QApplication(sys.argv)

DB = QSqlDatabase("QMYSQL3", "MyDatabase", app)

DB.setDatabaseName("MyDatabase")
DB.setUserName("root")
DB.setPassword("MyPassword")
DB.setHostName("localhost")
DB.open()

c = DB.execStatement("select * from MyTable")

while c.next():
print c.value(0).toString()
print c.value(1).toString()
print c.value(2).toString()
print c.value(3).toString()
c.first()

c2 = DB.execStatement("select count(*) from MyTable")
c2.next()

print c2.value(0).toString()
----------------------------------------------------

Some further documentation:
http://www.arl.hpc.mil/ice/Manuals/PyQt/t1.html
http://doc.trolltech.com/4.2/database.html

H.
 
Reply With Quote
 
hlubenow
Guest
Posts: n/a
 
      05-03-2007
hlubenow wrote:

> There's even another approach: ...


On the other hand you may be better off with the "mysql-python"-module.

Anyway, here's a nice overview over the most commonly used MySQL-commands
(The commands should speak for themselves, even if the explanations are in
German):

http://www.linux-club.de/ftopic49585.html

H.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Python and Connecting to MySQL remotely WITHOUT MySQL installedon local computer dave Python 4 11-18-2010 04:19 AM
MySQL-python-1.2.2 install with no mysql washakie Python 4 01-15-2008 08:15 PM
using mysql client to read a file to create a table in a database in a mysql server julian Ruby 8 04-06-2006 10:29 AM
"mysql.h: No such file or directory" when building MySQL-python francescomoi@europe.com Python 2 05-11-2005 03:12 PM
"Pure Python" MySQL module like Net::MySQL Ravi Python 6 07-21-2003 06:53 PM



Advertisments