[DB-SIG] InternalError

helena bhaska helena_b2001 at yahoo.com
Thu Jan 8 20:05:42 EST 2004


Thanks,
yes, in fact running test1.py as you suggested fails
with a Segmentation Fault...I'm going to try to
reinstall MySQLdb.

--- Chris Cogdon <chris at cogdon.org> wrote:
> 
> On Jan 8, 2004, at 16:19, helena bhaska wrote:
> 
> > class
> >
>
PurpleRequestHandler(SocketServer.BaseRequestHandler):
> >     def handle(self):
> >         while 1:
> >             rq = netstring.readns(self.request)
> >             if rq == "":
> >                 break
> >             dt = DateTime.now()
> >             db = MySQLdb.Connect(host="localhost",
> > user="root", passwd="password", db="Test")
> >             c = db.cursor()
> >             c.execute("""INSERT INTO Commands
> (Time,
> > Command) VALUES (%s, %s)""", (str(dt), rq))
> >             c.close()
> >             db.close()
> > purpleServer =
> SocketServer.ThreadingTCPServer(('',
> > 8081), PurpleRequestHandler)
> > purpleServer.serve_forever()
> >
> > The interesting part is that if my server runs on
> > apache and I connect to it through
> urllib.urlopen(),
> > the data is saved into the database just fine.  Is
> my
> > MySQL db not configured correctly or something?
> > Thanks for any pointers!
> 
> It's very odd that it's working via a apache CGI,
> but not through the 
> python server handlers. To test it out on my own
> machine, I wrote this 
> quick thing:
> 
> import SocketServer, MySQLdb
> 
> class Handler ( SocketServer.StreamRequestHandler ):
>      def handle ( self ):
>          while 1:
>              t = self.rfile.readline ()
>              if t == '': break
>              db = MySQLdb.Connect (
> host='localhost', user='root', 
> passwd='xxx', db='xxx' )
>              db.close ()
>              print "read command:", t
> 
> server = SocketServer.ThreadingTCPServer (
> ('',8081), Handler )
> server.serve_forever ()
> 
> ( I used the StreamRequestHandler because I don't
> have netstring :)
> 
> And then telnetted to port 8081 and typed a command.
> The command came 
> up just fine, and no error message from the MySQL
> Connect.
> 
> You might want to try and eliminate problems in the
> client, first, by 
> simply telnetting to your port 8081 and typing
> commands in netstring 
> format. Eg:
> 
> "5:Hello," (omit quotes)
> 
> If THAT works, then that's really odd. Narrow it
> down to this:
> 
> test1.py:
> 
> import MySQLdb
> db = MySQLdb.Connect ( host='localhost',
> user='root', passwd='xxx', 
> db='xxx' )
> 
> Run that... if that fails, then you've got problems
> in the MySQLdb 
> installation. If that works, try my script above, if
> that fails, then 
> ... well, I dont know :/
> 
> 
> One thing to ask... are the parameters to Connect
> for your SocketServer 
> version EXACTLY the same as the parameters for your
> apache CGI version?
> 
> 
> -- 
>     ("`-/")_.-'"``-._        Chris Cogdon
> <chris at cogdon.org>
>      . . `; -._    )-;-,_`)
>     (v_,)'  _  )`-.\  ``-'
>    _.- _..-_/ / ((.'
> ((,.-'   ((,/   fL
> 


__________________________________
Do you Yahoo!?
Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
http://hotjobs.sweepstakes.yahoo.com/signingbonus



More information about the DB-SIG mailing list