Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
pymssql 2.x does not support "%(foo)d" parameter substitution style; pymssql 1.x did #155
The PEP 249 support various params binding.
qmark is not supported:
cur.execute('select @@version where 1=?', (1,))
numeric is not supported:
cur.execute('select @@version where 1=:1', (1,))
named is not supported:
cur.execute('select @@version where 1=:name', dict(name=1))
format is partially supported:
cur.execute('select @@version where 1=%d', (1,)) # OK cur.execute('select @@version where 1=%1d', (1,)) # fail
pyformat does not support %(foo)d:
cur.execute('select @@version where 1=%(name)s', dict(name='1')) # OK cur.execute('select @@version where 1=%(name)d', dict(name=1)) # fail
paramstyle = 'pyformat'
But perhaps this should be mentioned in the new docs from @ramiro if it's not already there.
It sounds like you also might've found a problem with the pyformat stuff relating to '%(foo)d"? Is it the d (integer) specifically? The two lines you posted look identical; maybe a copy/paste error? Maybe the failing one should be d instead of s?
Looking at the code some more, I can see that pymssql advertises that it supports pyformat as I mentioned. However it also supports format (looking at the code for the
The tricky thing about pyformat is that if you look at PEP 249, the only example they show for pyformat is %(foo)s -- e.g.: with the s. It's not clear whether they meant that other things like d, f, or i are supported.
It seems that pymssql 1.X supported those extra forms though, whereas pymssql 2.X does not.
I see 3 options:
Let me know if you have other thoughts.
On 1/8/14, 1:38 AM, Marc Abramowitz wrote:
/"For what does it profit a man to gain the whole world
@kunxi but a major release is the place to break BC if we are going to break it.
Marc, I think this one is up to you since you are currently working on the code. From an idealist perspective, supporting the differing characters "%s, %d" implies some kind of different handling based on type, IMO. It seems best to avoid that. At the same time, it's not likely to cause much headache in practice, so....
So I'm closing this. @kunxi: If you run into problems and you have to have this, let me know and we can reopen.
Oh, I forgot to mention, that I added info about this to the docs: