Strange MySQL Problem...

Victor Subervi victorsubervi at gmail.com
Thu Apr 3 08:43:57 EDT 2008


Comments in line...
On Thu, Apr 3, 2008 at 12:35 AM, John Nagle <nagle at animats.com> wrote:

> Steve Holden wrote:
>


> Define "no longer works".
>

Sorry. Throws HTTP 200 error.

On Thu, Apr 3, 2008 at 12:35 AM, John Nagle <nagle at animats.com> wrote:

> John Nagle wrote:
> > "works fine"? Please check again...
> > The same remarks I've posted earlier apply here.
>

Must have missed those. Yes, the code works fine. Repeatedly.

>
>
>    In addition, you're not committing the database update.
> You need to do
>
>    connection.commit()


Oh, thanks :)

>
>
> after updating.
>
>    In general, server side programs should have a try-block
> wrapped around most of the program, with some code to display or
> log errors in some useful way.


Curious. Why? During testing, I understand, but after testing, why?

On Thu, Apr 3, 2008 at 12:35 AM, John Nagle <nagle at animats.com> wrote:

> Gabriel Genellina wrote:
>

> > print 'Content-Type: image/jpeg\r\n'
> > print '<html><body>\nHi!\n'
>
> Don't you see a conflict among those two lines?
> (You're a liar: first you promise to send a nice picture and then you only
> send a letter!)
>

LOL! Okay, make me honest ;) I want to post both text and images. What use?


>
>
> > cursor.execute("CREATE TABLE justatest (name TEXT, ablob BLOB)")
>
> Note that you *always* attempt to create a table.
>

Yeah, I am dropping it, too. This was just some code I found online and
tweaked.


>
>
> > sql = "INSERT INTO justatest VALUES (%s, %s)"
> > cursor.execute(sql, ('ramis', _mysql.escape_string(f)) )
>
> You're using bound parameters now, a good thing. There is no need to
> escape strings passed as parameters - in fact, it is wrong, as the adapter
> will escape the text again.
> In this case, the column is a BLOB, and you have to use the Binary
> function: MySQLdb.Binary(f)
>

Nope. Threw me another HTTP 200.


> > Now, if I take out this part, which I can´t see does anything at all in
> > the
> > code, it no longer works:
>
> I don't think "it no longer works" because you removed anything, but
> because this script can only be run at most once. Probably you're getting
> an error in the CREATE TABLE statement.
>

Wrong. I check the mysql and drop the table if the code throws me an HTTP
200 error. I have run this code many times now. That is what makes the whole
thing so ridiculously strange to me. That code snippet, that the script
insists on, is a relic from the code I tweaked. It was there to make a
binary, that is all. So why do I still need the darn thing??

>
> You have to look at the server error logs, else you're blind fighting.
>

I am blind fighting. No longer run my own server, no longer have root
access.


> See
> other suggestions in my previous post.
>

Sorry. Can you repost it?
TIA,
Victor
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080403/617fcb90/attachment.html>


More information about the Python-list mailing list