Re: [sqlite] SQLITE Binding Issue when using [] brackets
On 4/1/2012 4:23 PM, ap wrote: http://sqlite.org/c3ref/bind_blob.html Brackets are recommended for attribute names in some cases, it seems the binding for :VVV does not permit :[VVV]. Is this the case? This is the case. Parameter names must be proper identifiers. recdct {'[c1]': 1, '[c2]': 2} cur.execute("""INSERT INTO merge ([c1],[c2]) VALUES ( :[c1], :[c2] )""",recdct) Nothing says that parameter names must match column names. You could name your parameters :c1 and :c2, or :x and :y, or :foo and :bar. -- Igor Tandetnik ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] SQLITE Binding Issue when using [] brackets
On 1 April 2012 21:23, ap wrote: > > http://sqlite.org/c3ref/bind_blob.html > > Brackets are recommended for attribute names in some cases, it seems the > binding for :VVV does not permit :[VVV]. Is this the case? Square brackets are a quoting mechanism for identifiers supported for compatibility with MS Access and SQL Server. (http://www.sqlite.org/lang_keywords.html) > > I prefer the dictionary binding if possible. Normally no issues, however > when I introduce brackets there may be an issue. Is this the appropriate > syntax? ([c1],[c2]) VALUES ( :[c1], :[c2] ) I don't think so. The column names are c1 and c2 - the square brackets are a quoting mechanism, not part of the name. Try ([c1],[c2]) VALUES ( :c1, :c2 ) > recdct > {'[c1]': 1, '[c2]': 2} > cur.execute("""INSERT INTO merge ([c1],[c2]) VALUES ( :[c1], :[c2] )""",recdct) > Traceback (most recent call last): > File "", line 1, in > cur.execute("""INSERT INTO merge ([c1],[c2]) VALUES ( :[c1], : > [c2] )""",recdct) > OperationalError: unrecognized token: ":" > Regards, Simon ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
[sqlite] SQLITE Binding Issue when using [] brackets
http://sqlite.org/c3ref/bind_blob.html Brackets are recommended for attribute names in some cases, it seems the binding for :VVV does not permit :[VVV]. Is this the case? I prefer the dictionary binding if possible. Normally no issues, however when I introduce brackets there may be an issue. Is this the appropriate syntax? ([c1],[c2]) VALUES ( :[c1], :[c2] ) >>> recdct {'[c1]': 1, '[c2]': 2} >>> cur.execute("""INSERT INTO merge ([c1],[c2]) VALUES ( :[c1], :[c2] >>> )""",recdct) Traceback (most recent call last): File "", line 1, in cur.execute("""INSERT INTO merge ([c1],[c2]) VALUES ( :[c1], : [c2] )""",recdct) OperationalError: unrecognized token: ":" >>> ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users