R
rshepard
I'm a bit embarrassed to have to ask for help on this, but I'm not finding
the solution in the docs I have here.
Data are assembled for writing to a database table. A representative tuple
looks like this:
('eco', "(u'Roads',)", 0.073969887301348305)
Pysqlite doesn't like the format of the middle term:
pysqlite2.dbapi2.InterfaceError: Error binding parameter 1 - probably
unsupported type.
I want to extract the 'Roads', part from the double-quoted enclosing
tuple. The unicode part should be automatically removed when the string is
printed, but I suspect it's the double quotes and extra parentheses that are
the problem. I know that tuples are immutable, but I thought that I could
slice it. If so, I'm not doing it correctly, because each attempt results in
TypeError: unsubscriptable object
Even when I assign that middle term to a variable before assembling the
tuple for insertion in the database, I just cannot get the job done. Whether
in the tuple of three terms or by itself, I haven't applied the proper
technique.
Insight appreciated.
Rich
the solution in the docs I have here.
Data are assembled for writing to a database table. A representative tuple
looks like this:
('eco', "(u'Roads',)", 0.073969887301348305)
Pysqlite doesn't like the format of the middle term:
pysqlite2.dbapi2.InterfaceError: Error binding parameter 1 - probably
unsupported type.
I want to extract the 'Roads', part from the double-quoted enclosing
tuple. The unicode part should be automatically removed when the string is
printed, but I suspect it's the double quotes and extra parentheses that are
the problem. I know that tuples are immutable, but I thought that I could
slice it. If so, I'm not doing it correctly, because each attempt results in
TypeError: unsubscriptable object
Even when I assign that middle term to a variable before assembling the
tuple for insertion in the database, I just cannot get the job done. Whether
in the tuple of three terms or by itself, I haven't applied the proper
technique.
Insight appreciated.
Rich