Michael--thanks for your help. As you probably guessed, I'm still running
0.5. DEFAULT is, in fact, a valid MySQL keyword, though I didn't know about
it before looking into this problem.
On Wed, May 19, 2010 at 10:09 AM, Michael Bayer mike...@zzzcomputing.comwrote:
On May 18, 2010, at 10:06 PM, Dan Kuebrich wrote:
My apologies; I expressed my question rather incoherently.
if the question is, I want to multiple insert like [{'a':1, 'b':2, 'c':3},
{'a':2}, {'a':3, 'b':4}], etc. only some dictionaries are missing different
keys, that is not allowed. The structure of the SQL statement as parsed by
MySQL determines for which columns the server-side default is emitted and
there is only one version of that with an executemany. So every param
dictionary must have at least all the keys which the first one does.
This was the basic scenario of my question. However, unless I
misunderstand, it does seem to be allowed: the missing values are replaced
with NULL in the generated query.
it should not be in SQLA 0.6.Specific logic was added to disallow this.
But what I actually meant to ask was this: sqlalchemy handles missing
dictionary entries as NULL for the purpose of inserts, is there an easy way
to have it generate a SQL statement with DEFAULT for missing dictionary
entries?
Eg. execute(testtable.insert(), [{'a':1, 'b':2, 'c':3}, {'a':2}, {'a':3,
'b':4}]) = INSERT INTO testtable (a,b,c) VALUES
(1,2,3),(2,DEFAULT,DEFAULT),(3,4,DEFAULT)
ive never seen that syntax before (i.e. DEFAULT is actually present as a
value).Assuming its valid, you could achieve it using a client side
default as I mentioned earlier.i.e. Column('foo', Integer,
default=text('DEFAULT')). But again, not with an executemany() and
heterogeneous dictinoaries as you have above. The SQL statement is
rendered only once, and either has a bind parameter for a particular
position or not.
--
You received this message because you are subscribed to the Google Groups
sqlalchemy group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to
sqlalchemy+unsubscr...@googlegroups.comsqlalchemy%2bunsubscr...@googlegroups.com
.
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.
--
You received this message because you are subscribed to the Google Groups
sqlalchemy group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.