473,413 Members | 1,811 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,413 software developers and data experts.

Using python with MySQL


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

May 1 '07 #1
6 2079
On 1 May 2007 12:40:20 -0700, HMS Surprise <jo**@datavoiceint.comwrote:
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/
May 1 '07 #2
On May 1, 10:40 pm, HMS Surprise <j...@datavoiceint.comwrote:
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

May 1 '07 #3
On May 1, 2:58 pm, "Greg Donald" <gdon...@gmail.comwrote:
On 1 May 2007 12:40:20 -0700, HMS Surprise <j...@datavoiceint.comwrote:
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

May 1 '07 #4
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

May 1 '07 #5
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.
May 3 '07 #6
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.
May 3 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Yong Wang | last post by:
Hi, All: We have a network management system written in C++, MysQL, and Hp SNMP. It works in Solaris command line. When I wrote a similar python codes which call compiled C++ and mysql codes in...
1
by: Dave Ekhaus | last post by:
hi my news carrier didn't have any mysql specific news groups - so apologize in advance if this isn't exactly the proper group for these question(s) ... anyway - i'm trying to figure out how...
2
by: Cathy Hui | last post by:
Do u know why do i get the following message when trying to build the MySql-Python (1.2.0) on my Solaris 8 system? (with mysql 4.0.21 and python 2.4). thanks! error mesg: ld: fatal:...
10
by: callmebill | last post by:
I'm getting my feet wet with making Python talk to MySQL via ODBC. I started on Windows, and it went smoothly enough due to the ODBC stuff that apparently is native to Python at least on windows...
2
by: Richard Brosnahan | last post by:
I hate asking questions that have probably been answered before, but I have not found a way to conveniently search the archives of this mailing list. So... Can someone tell me how to...
48
by: northband | last post by:
Hi, I am interested in re-writing my website in Python vs PHP but have a few questions. Here are my specs, please advise as to which configuration would be best: 1.Dell Poweredge Server, w/IIS,...
14
by: Ben | last post by:
I don't know whether anyone can help, but I have an odd problem. I have a PSP (Spyce) script that makes many calls to populate a database. They all work without any problem except for one...
11
by: Monty Taylor | last post by:
Hey everybody, MySQL has put up a poll on http://dev.mysql.com asking what your primary programming language is. Even if you don't use MySQL - please go stick in a vote for Python. I'm...
2
by: Nikhil | last post by:
I am using the MySQLdb python module. I have a table named 'testing' with few columns, under the 'test' database, what is hosted on a remote mysql server. I want to run the following query to...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.