Re: Using .capitalize() in Insert Statement

Rich Shepard <[email protected]>
Newsgroups gmane.comp.python.db.pysqlite.user
Message-ID <[email protected]>
On Mon, 12 Feb 2007, Gerhard Häring wrote:

> No, of course you can:

   Thank you, Gerhard. That's what I thought. However, I was not sure about
the implementation.

> cur.execute("insert into foo(bar) values (?)", ("xyz".capitalize(),))

   This is what I did everywhere I had a text field that could be matched
against one from a different table.

> I don't think there's a SQL function capitalize, but you can of course
> create one:
>
>>>> from pysqlite2 import dbapi2 as sqlite
>>>> import string
>>>> con = sqlite.connect(":memory:")
>>>> con.create_function("capitalize", 1, string.capitalize)
>>>> con.execute("select capitalize('foo')").fetchone()
> (u'Foo',)

   Do I create the function once, in the modele that creates the connection
for the model? That seems to be correct, but having no previous experience
with sqlite in a python application I want to be certain I correctly
understand.

Rich

-- 
Richard B. Shepard, Ph.D.               |    The Environmental Permitting
Applied Ecosystem Services, Inc.        |          Accelerator(TM)
<http://www.appl-ecosys.com>     Voice: 503-667-4517      Fax: 503-667-8863

_______________________________________________
pysqlite mailing list
pysqlite-IAPFreCvJWPBWskQ1e/[email protected]
http://lists.initd.org/mailman/listinfo/pysqlite
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.