[DB-SIG] Problem with mxODBC, please reply

Khawaja-Shahzad Butt kshahzadbutt at gmail.com
Wed Oct 13 16:23:55 CEST 2004


Hello Mr. Guido,
                    Since you are the father of python. I just need this
clarification. I am not sure what syntax/parameter marker to 
use for mx.ODBC insert statement.

The following works but it's not optimal way to insert:
It gives weird exceptions. (just the insert statement).

q = "insert into rss_fee
feed_title,feed_url,feed_description,feed_rss_version,feed_status)\
    values('%s','%s','%s','%s','%s')" %
(feedtitle,feedurl,feeddescription,feed_version,feed_status)

q=q.encode("utf-8");    
    c.execute(q)

this is another insert statement but a different one:

c.execute ( "INSERT INTO
rss_feed_items(item_date,item_title,item_author,item_permalink,item_description)\
    VALUES(%s,%s,%s,%s,%s)",(item_dmodified,
feed_item_title,item_author, feed_item_link,feed_item_feeddescription)
)

I get this exception:
Traceback (most recent call last):
  File "C:\Python23\Lib\site-packages\Pythonwin\pywin\framework\scriptutils.py",
line 310, in RunScript
    exec codeObject in __main__.__dict__
  File "C:\feedparser-3.3\feedparser\test.py", line 550, in ?
    info_extract(data,url);
  File "C:\feedparser-3.3\feedparser\test.py", line 41, in info_extract
    rss_20extraction(result,url)
  File "C:\feedparser-3.3\feedparser\test.py", line 312, in rss_20extraction
    dbinsertfeeditem(feed_item_title,feed_item_link,item_author,feed_item_feeddescription,item_dmodified)
  File "C:\feedparser-3.3\feedparser\test.py", line 415, in dbinsertfeeditem
    c.execute ( "INSERT INTO
rss_feed_items(item_date,item_title,item_author,item_permalink,item_description)\
InterfaceError: number of parameters in tuple 0: expected 0, found 5


Mark hammond's book on python win32 book doesn't go into much 
depth about mxODBC. Although steve holden's book has good 
concepts but lack a lot of examples .

I looked through DB-API and mxODBC specs but nothing talks about insert
statement and also should i autocommit or not.
I am using winxp and activestate win python as IDE, SQL server 2000 as back db.

Please reply,.
Thank you for you time.
I would be grateful
Regards
Shahzad


More information about the DB-SIG mailing list