trouble installing MySQLdb (cygwin) + Bonus question

2011-01-24 Thread Matthew Roth
Hi,
I'm a python newbie. By newbie I mean two days ago.
It was suggested to me that I work with python.
Unfortunately at work I must run this on a windows machiene.

However, I am having difficultly installing MySQLdb.

First is it even possible under my current environment?
I am using python(2.6.5) through cygwin, and have mySQL(Ver 14.14
Distrib 5.5.8 for Win32) installed in windows 7

which mysql returns:
/cygdrive/c/Program Files/MySQL/MySQL Server 5.5/bin/mysql

when I run
python setup.py build it returns:
--
$ python setup.py build
/bin/sh: mysql_config: command not found
Traceback (most recent call last):
File "setup.py", line 15, in 
metadata, options = get_config()
File "/home/Matt/MySQL-python-1.2.3/setup_posix.py", line 43, in
get_config
libs = mysql_config("libs_r")
File "/home/Matt/MySQL-python-1.2.3/setup_posix.py", line 24, in
mysql_config
raise EnvironmentError("%s not found" % (mysql_config.path,))
EnvironmentError: mysql_config not found
--

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.

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)

--

why is this a poor idea?

Best,
Matt
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: trouble installing MySQLdb (cygwin) + Bonus question

2011-01-25 Thread Matthew Roth
On Jan 25, 4:30 am, Dennis Lee Bieber  wrote:
> On Mon, 24 Jan 2011 14:25:09 -0800 (PST), Matthew Roth
>  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 '';

   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...@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: trouble installing MySQLdb (cygwin) + Bonus question

2011-01-25 Thread Matthew Roth
Thank you. I appreciate you explanation and tolerance of my
ignorance.

However unfortunate, this still does not solve my major issue.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: trouble installing MySQLdb (cygwin) + Bonus question

2011-01-25 Thread Matthew Roth
On Jan 25, 9:34 pm, John Nagle  wrote:
> On 1/25/2011 7:05 AM, Matthew Roth wrote:
>
> > On Jan 25, 4:30 am, Dennis Lee Bieber  wrote:
> >> On Mon, 24 Jan 2011 14:25:09 -0800 (PST), Matthew Roth
> >>   declaimed the following in
> >> gmane.comp.python.general:
> >>          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.
>
>     You can install a MySQL server under Windows, and talk to the server
> from the Cygwin environment.  That's a useful way to test.
>
>                                         John Nagle

Right, that is precisely what I have. I am able to talk to it from
cygwin, however, during the installing of the MySQLdb module it cannot
find the mysql_config. This is because It is not installed? The setup
sees that I am on a posix system not windows, as python is installed
in cygwin, a virtual posix system. I am trying to bulid a mysql client
from source for cygwin, however, I am running into an error there.

Unless, can I talk to the windows mysql_config? if so, what does that
look like

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: trouble installing MySQLdb (cygwin) + Bonus question

2011-01-25 Thread Matthew Roth
On Jan 25, 6:20 pm, David Robinow  wrote:
> On Tue, Jan 25, 2011 at 5:59 PM, Matthew Roth  wrote:
> > On Jan 25, 9:34 pm, John Nagle  wrote:
> ...
> >>     You can install a MySQL server under Windows, and talk to the server
> >> from the Cygwin environment.  That's a useful way to test.
>
> >>                                         John Nagle
>
> > Right, that is precisely what I have. I am able to talk to it from
> > cygwin, however, during the installing of the MySQLdb module it cannot
> > find the mysql_config. This is because It is not installed? The setup
> > sees that I am on a posix system not windows, as python is installed
> > in cygwin, a virtual posix system. I am trying to bulid a mysql client
> > from source for cygwin, however, I am running into an error there.
>
> > Unless, can I talk to the windows mysql_config? if so, what does that
> > look like
>
>  The obvious answer is to use a Windows python. You haven't explained
> why you think you need to run a cygwin python. Can you explain that?


Good question. There isn't a solid explanation. heretofore, I have
been using a lot of bash scripting in combination with awk sed and
some perl. I was directed to look into python. My tasks were becoming
increasingly complex and memory intensive. I started with a desire to
connect to a mysql server. For that I needed to install the MySQLdb
module. I am having difficultly in acomplishment of this task. I
suppose for the time it has taken, using windows python would have
been the simpler route.


Anyway, I have done some tinkering and have moved passed the
mysql_config problem. Thanks to Davids reminder that I have mysql on
windows. Meaning when setup.py called setup_posix.py It was
essentially calling mysql_config. Well mysql_config was in a far off
folder. I setup a symbolic link and that worked. However I was then
presented with a new problem. In direct relation to that far off
folder. Dreaded spaces. (i headed the log)

--
 running build
 running build_py
 copying MySQLdb/release.py -> build/lib.cygwin-1.7.7-i686-2.6/MySQLdb
 running build_ext
 building '_mysql' extension
 creating build/temp.cygwin-1.7.7-i686-2.6
 gcc -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-
prototypes -Dversion_info=(1,2,3,'final'
 ,0) -D__version__=1.2.3 -I/usr/include/python2.6 -c _mysql.c -o build/
temp.cygwin-1.7.7-i686-2.6/_mysql.
 o "-I/cygdrive/c/Program Files/MySQL/MySQL Server 5.5/include" "/MT"
"/Zi" "/O2" "/Ob1" "/D" "NDEBUG" "-
 DDBUG_OFF"
 gcc: "-I/cygdrive/c/Program: No such file or directory
--

there is much more, but obviously the problem is " gcc: "-I/cygdrive/c/
Program: No such file or directory"

what I need to do is have it point to /cygdrive/c/Program\ Files/MySQL/
MySQL\ Server\ 5.5/include and not cygdrive/c/Program Files/MySQL/
MySQL Server 5.5/include.

I am currently trying to track that down. I think I am going to leave
work and go grab some dinner. perhaps I will solve this later tonight.

Best,
Matt

-- 
http://mail.python.org/mailman/listinfo/python-list