[egenix-users] Fwd: [egenix-info] Problems with mxODBC please reply.

Charlie Clark support at egenix.com
Mon Oct 11 17:40:59 CEST 2004


Dear Shazad,

sorry to hear you are having problems but they don't seem to be related to 
mxODBC specifically which is extensively documented. Are you using IDLE? We 
have a free mailing list for mxODBC users but you can also try the main 
Python mailing list.

Good luck!

Charlie Clark

On [egenix-info] Problems with mxODBC please reply. at 16:22:41 [+0200], 
Khawaja-Shahzad Butt <kshahzadbutt at gmail.com> wrote:
> Hello,
> 
>            I am a student at iowa state university. i am using mx.ODBC for
> purpose of interfacing python with MSSQL server. There is no manual
> or information on how to use SQL queries with mxODBC.
> I have installed both base and commerical package. In order to get
> support or your help do i have to purchase a license since i am student
> and am just experiementing.
> 
> I have spent countless hours on the erros and still finding a way to
> eliminate all exceptions ( like ASCII decoding error, unicode error
> Ordinal not in range (128)) .. etc.
> 
> The following python code has SQL query which is giving me problem.
> def 
> dbinsertfeeditem(feed_item_title,feed_item_link,item_author,feed_item_feedde
> scription,item_dmodified):
> 
>    db = mx.ODBC.Windows.DriverConnect('DSN=**;UID=**;PWD=***')
>    c = db.cursor()
> 
>    #c.execute('insert into rss_feed
> (feed_title,feed_url,feed_description,feed_rss_version)
> values('%s','%s');')
>    #c.execute("insert into rss_feed(feed_title,feed_url)
> values('%s','%s')" % (title,feed_url))
> 
>    dq= "delete from rss_feed_items"
>    c.execute(dq)
> 
> ##    print " q is", fid_q
>    ##    int(feed_id) # convert string to int  // type(object) to
> check object type
>    # to check an object/string is unicode type isinstance(str, unicode)
> 
>    q = "insert into
> rss_feed_items(item_date,item_title,item_author,item_permalink,item_descript
> ion)\
>    values('%s','%s','%s','%s','%s')" %
> (item_dmodified,feed_item_title,item_author,feed_item_link,feed_item_feeddes
> cription)
> 
> ##    q = "insert into rss_feed_items"
> 
>    #c.execute ("""BEGIN""")
>    #q ="""insert into rss_feed(feed_title,feed_url)
> values("%s","%s")""" % (title,feed_url)
>    #q = "insert into rss_feed(feed_url) values('%s')" % (feed_url)
>    #q1="""insert into rss_feed(feed_description) values("%s")""" % (summary)
>    #q2= "insert into provider(provider_name) values('%s')" % (auth)
>    q=q.encode("utf-8");
> ##    q2=q2.encode("utf-8");
>    #q1=q1.encode("utf-8");
> ##    
> c.execute(q,(item_dmodified,feed_item_title,item_author,feed_item_link,feed_
> item_feeddescription))
>      #c.execute("insert into rss_feed_items values(?,?,?,?,?)",
> (item_dmodified,feed_item_title,item_author,feed_item_link,feed_item_feeddes
> cription))
>    c.execute(q)
>    #c.execute(q2)
> 
> ##    c.execute(q,
> item_dmodified,feed_item_title,item_author,feed_item_link,feed_item_feeddesc
> ription)
> ##    c.execute(q,
> (item_dmodified,feed_item_title,item_author,feed_item_link,feed_item_feeddes
> cription)
> )
> 
> ##    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_ite
> m_link,feed_item_feeddescription)
> )
> 
>    #c.execute(q1)
> 
>    db.commit()
> 
>    fid_q="select feed_id from rss_feed "
>    fid_q=fid_q.encode("utf-8");
>    c.execute(fid_q)
>    row=c.fetchall()
>    c.tables(None,None,None,None)
> 
>    print "Hello=",row
>    print "length of tuple=",len(row)
> 
> ##    q3 = "insert into rss_feed_items(feed_id)   values(%s')" % (fid_q)
> 
> ##    c.execute(q3)
>    db.commit()
>    #print q
> 
>    c.close()
>    db.close()
> 
> Please tell is there another way of using SQL with mxODBC for insert, 
> delete,
> update and select.
> 
> Also should i use mxZope adaptor or not if i want to read and write
> simutaneously
> to the SQL server.
> 
> Please reply . I hope you will help a student.
> Regards
> Shahzad
-- 
Charlie Clark
eGenix.com

Professional Python Services directly from the Source
 >>> Python/Zope Consulting and Support ...        http://www.egenix.com/
 >>> mxODBC.Zope.Database.Adapter ...             http://zope.egenix.com/
 >>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
________________________________________________________________________

::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! ::::



More information about the egenix-users mailing list