trouble installing MySQLdb (cygwin) + Bonus question

Matthew Roth mgroth86 at gmail.com
Tue Jan 25 10:05:50 EST 2011


On Jan 25, 4:30 am, Dennis Lee Bieber <wlfr... at ix.netcom.com> wrote:
> On Mon, 24 Jan 2011 14:25:09 -0800 (PST), Matthew Roth
> <mgrot... at gmail.com> declaimed the following in
> gmane.comp.python.general:
>
>
>
> > I've explored various avenues all day to no avail. Can anyone offer a
> > solution or a direction to work towards. One avenue was ignorning the
> > check for posix, and having it run setup_windows, but this just brings
> > in problems with _winreg(?) seeing how I have a posix version of
> > python through cygwin.
>
>         Maybe you need the development headers for MySQL?
--
I do believe I have them. Perhaps I need to find the correct way to
point to them.
I believe it is looking for the dev headers for a linux client when I
am using a client for windows via cygwin.

Or perhaps I should look into installing a separate linux mysql client
in cygwin.
I read of a similiar problem with perl, but the documentation felt a
bit dated and several steps would no longer function correctly.

>
> > Lastly, for the bonus question.
> > Why MySQLdb why not something like this:
> > --
> > import os
> > cmd = 'mysql -uroot -pxxx db -e "SELECT * FROM tblxxx;"'
> > os.system(cmd)
>
>         Passing username/password to a shell command that might be parsed by
> some outside process? Security leak!
--
I do indeed see that. However, all my python calls will be done within
my local intranet.
But is this a reason to not use os module at all? fetching a
dirlisting or mkdir is still
a valid reason to use the os Module, correct?
>
>         Second -- MySQL is a server model DBMS; it doesn't have to be on the
> local machine.
--
unfortunately, for my use it does. We do have an old centOs box here,
but the mysql running on that is severely outdated and so too is the
python.
I have been discouraged from upgrading the former, and the latter I
was told only if I could do it through yum. Making an altinstall form
source seems to be
discouraged. Good news is I think they have decided to upgrade our
development box.
>
>         Third -- ever heard of TRANSACTIONS? How would you handle a
> transaction if every SQL statement was a totally independent process?
> --
No. quite to my embarrassment I haven't. But this is not to say I have
not used them. It sounds as if I have.
But, you can put more than one sql statement into a cmdline.
mysql = "mysql -uuser -ppass db -e \"SELECT CURTIME();
           CREATE TABLE tempTBL (
           freq INT,
           x INT,
           y VARCHAR(255),
           PRIMARY KEY(x, y);

           LOAD XML INFLE 'doc'
           INTO TABLE tempTBL
           ROWS IDENTIFIED BY '<line>';

           INSERT INTO freqTbl(x,y,freq)
           SELECT x,y,freq FROM tempTBL
           ON DUPLICATE KEY UPDATE freq=tempTbl.freq+freqTbl.freq;

           SELECT CURTIME();\"
os.system(mysql)

I haven't tested that, but I know it works at the command line.
I do fully intend to use MySQLdb through python and conduct more of
the processing and parsing in python. It will be a learning
experience. I have a background in anthropology, not computer science.
But I love learning all this, and love that my place of employment
encourages me to learn this. Unfortunately with self-learning you can
sometimes miss out on important concepts and still accomplish tasks.

Thank you for your reply.


>         Wulfraed                 Dennis Lee Bieber         AF6VN
>         wlfr... at ix.netcom.com    HTTP://wlfraed.home.netcom.com/




More information about the Python-list mailing list