Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Help don't know what problem is Newbie

Reply
Thread Tools

Help don't know what problem is Newbie

 
 
len
Guest
Posts: n/a
 
      08-23-2006
Have the following code:

import os
import csv
import re
import mx.ODBC
import mx.ODBC.Windows

currdir = os.getcwd()
db = mx.ODBC.Windows.DriverConnect('dsn=UICPS Test')
c = db.cursor()
sid = 315

matchstr = re.compile(r'\(*\)*-*,*')
reader = csv.reader(open(currdir + r'\\IBI Brokers List 8-21-06.csv'))

for rec in reader:
if rec[0] != '' or rec[1] != '':
if rec[0] == 'Name:':
orec = ''
orec = orec + rec[12] + ',' + rec[2]
elif rec[1] == 'Address1':
orec = orec + ',' + rec[4]
elif rec[1] == 'Address2':
orec = orec + ',' + rec[4]
elif rec[1] == 'City, State, ZIP':
csz = matchstr.sub('', rec[4]).split()
if len(csz) == 0:
c = ''
s = ''
z = ''
elif len(csz) == 3:
c = csz[0]
s = csz[1]
z = csz[2]
elif len(csz) == 4:
c = csz[0] + ' ' + csz[1]
s = csz[2]
z = csz[3]
orec = orec + ',' + c + ',' + s + ',' + z + ',' +
matchstr.sub('', rec[13])
elif rec[1] == 'Tax ID':
orec = orec + ',' + rec[4].replace('-', '') + ',' +
matchstr.sub('', rec[12])
sid += 1
orec = str(sid) + ',' + orec
print orec
c.execute("insert into Producer \
(Producer_Sid, Producerno, Company, Street, Suitepo, City,
State, Zip, \
Phone, Taxid, Fax) \
values (" + orec + ")")

Below is a listing of the orec which I printed along with the python
error:

[DEBUG ON]
>>>

316,001,#001 Insurance Brokers of Indiana,400 Camby Court,P O Box
190,Greenwood,IN,46142,3178882593 ,351539405,3178857011

Traceback (most recent call last):
File "C:\UICPS\IBIagent.py", line 44, in -toplevel-
c.execute("insert into Producer \
AttributeError: 'str' object has no attribute 'execute'

Thanks
Len Sumnler

 
Reply With Quote
 
 
 
 
Peter Otten
Guest
Posts: n/a
 
      08-23-2006
len wrote:


> Have the following code:


Short variable names increase the likelihood of name clashes:

> c = db.cursor()


> c = ''


> c = csz[0]


> c = csz[0] + ' ' + csz[1]
> c.execute("insert into Producer \
> (Producer_Sid, Producerno, Company, Street, Suitepo, City,
> State, Zip, \
> Phone, Taxid, Fax) \
> values (" + orec + ")")


Peter

 
Reply With Quote
 
 
 
 
len
Guest
Posts: n/a
 
      08-24-2006
Sorry for the stupid question. I was fixated on the SQL.

Thanks
Len Sumnler

Peter Otten wrote:
> len wrote:
>
>
> > Have the following code:

>
> Short variable names increase the likelihood of name clashes:
>
> > c = db.cursor()

>
> > c = ''

>
> > c = csz[0]

>
> > c = csz[0] + ' ' + csz[1]
> > c.execute("insert into Producer \
> > (Producer_Sid, Producerno, Company, Street, Suitepo, City,
> > State, Zip, \
> > Phone, Taxid, Fax) \
> > values (" + orec + ")")

>
> Peter


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
"Microsoft Certification - It's how they know you know" MatrixVic MCSD 0 02-03-2006 02:53 AM
"Microsoft Certification - It's how they know you know" MatrixVic MCSD 0 02-03-2006 02:52 AM
ISAKMP NAT problem (I know it can be done but don't know how) Rogier Mulder Cisco 1 01-13-2005 08:48 PM
I know, I know, I don't know Andries Perl Misc 3 04-23-2004 02:17 AM
Don know Perl, don't know what's broke - re - type1inst!! DP Perl 0 07-17-2003 10:22 PM



Advertisments