Inserting into a database
Stephen Hansen
apt.shansen at gmail.com
Sun Oct 11 21:09:12 EDT 2009
On Sun, Oct 11, 2009 at 5:06 PM, aditya shukla
<adityashukla1983 at gmail.com>wrote:
> this what the code looks like.
>
>
> db = MySQLdb.connect("localhost","root","juventus12","factoids",charset =
> "utf8", use_unicode = True )
> cursor= db.cursor() # i added charset = "utf8", use_unicode = True just
> now and changed the character set of mysql still no help.
>
> cursor.execute("""INSERT INTO question_table
> (question_id,source_id,question) VALUES (5,1,"question")""")
>
>
First, I just suggest you use single quotes around string data in SQL. Even
though mySQL allows double quotes in that context.
Second, it looks like you just need to commit. E.g., "db.commit()"
--S
>
> language, output_encoding = locale.getdefaultlocale()
>
> print output_encoding, language
>
>
> traceback
>
> C:\Python26\lib\site-packages\MySQLdb\__init__.py:34: DeprecationWarning:
> the sets module is deprecated
> from sets import ImmutableSet
>
> cp1252 en_US
>
> Thanks
>
> Aditya
>
>
>
>
>
>
>
>
>
>
>
>
>
>
--
Stephen Hansen
Development
Advanced Prepress Technology
shansen at advpubtech.com
(818) 748-9282
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20091011/be6ef15b/attachment-0001.html>
More information about the Python-list
mailing list