Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #35089
| From | Dennis Lee Bieber <wlfraed@ix.netcom.com> |
|---|---|
| Subject | Re: Why Doesn't This MySQL Statement Execute? |
| Date | 2012-12-19 00:40 -0500 |
| Organization | > Bestiaria Support Staff < |
| References | <mailman.1029.1355866451.29569.python-list@python.org> <50d0f4c7$0$6952$e4fe514c@news2.news.xs4all.nl> <mailman.1037.1355875874.29569.python-list@python.org> <kardvl$6u7$1@reader1.panix.com> <CAPTjJmp0xRsv+ibGxcdv3Nq-ZBsZU4HW7QfvO1XWthTwEs0isQ@mail.gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1039.1355895615.29569.python-list@python.org> (permalink) |
On Wed, 19 Dec 2012 15:49:41 +1100, Chris Angelico <rosuav@gmail.com>
declaimed the following in gmane.comp.python.general:
> On Wed, Dec 19, 2012 at 2:57 PM, John Gordon <gordon@panix.com> wrote:
> > In <mailman.1037.1355875874.29569.python-list@python.org> Tom Borkin <borkintom@gmail.com> writes:
> >
> >> Actually, what I originally had was:
> >> cursor.execute("""insert into interactions values(Null, %s, "Call Back",
> >> %s)""", (i_id, date_plus_2))
> >> and that didn't work, either. I tried your variation like:
> >> cursor.execute("""insert into interactions values(Null, %s, "Call Back",
> >> %s)""" % (i_id, date_plus_2))
> >> and no cigar :(
> >> Tom
> >
> > Have you tried using single-quotes around Call Back, instead of
> > double quotes? I've noticed that SQL statements prefer single-quoted
> > strings (although that may be Oracle specific, as that's all I've really
> > worked with).
>
> The SQL standard specifies single quotes, but MySQL and the SQL
> standard aren't always on speaking terms. It depends on the MySQL
> settings as to whether "asdf" means 'asdf' or means a column named
> asdf.
>
> But if that's what the problem is, there ought to be an exception
> coming back, surely? I'm not familiar with the Python MySQL bindings,
> but that's what I would expect. What, specifically, does "no cigar"
> mean? It executes without errors but does nothing? It purchases a gun,
> aims at your shoe, and pulls the trigger?
>
Well... off the wall...
I'm going to presume the first field -- the Null -- is for a primary
key (autoincrement)...
What happens if you change the SQL to actually specify the columns
being filled AND you ignore the primary key/Null entry?
And since I don't like hard-coding the SQL...
cursor.execute("""insert into interactions (someID, action, somedate)
values (%s, %s, %s)""",
(i_id, "Call Back", date_plus_2) )
Of course you need to use the actual table column names...
--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Why Doesn't This MySQL Statement Execute? Tom Borkin <borkintom@gmail.com> - 2012-12-18 17:34 -0400
Re: Why Doesn't This MySQL Statement Execute? Hans Mulder <hansmu@xs4all.nl> - 2012-12-18 23:57 +0100
Re: Why Doesn't This MySQL Statement Execute? Tom Borkin <borkintom@gmail.com> - 2012-12-18 20:11 -0400
Re: Why Doesn't This MySQL Statement Execute? John Gordon <gordon@panix.com> - 2012-12-19 03:57 +0000
Re: Why Doesn't This MySQL Statement Execute? Chris Angelico <rosuav@gmail.com> - 2012-12-19 15:49 +1100
Re: Why Doesn't This MySQL Statement Execute? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-12-19 00:40 -0500
Re: Why Doesn't This MySQL Statement Execute? Alister <alister.ware@ntlworld.com> - 2012-12-19 13:28 +0000
csiph-web