List limitations?

Daley, MarkX markx.daley at intel.com
Thu Mar 23 16:58:35 CET 2000


OK, here's a good one:

I am using this glorious little piece of code, which I will explain in
detail:

def collect():
	familyname = ['name1', 'name2', 'name3', 'name4', 'name5', 'name6',
'name7', 'name8', 'name9', 'name10', 'name11', 'name12']
	servername = ['server1', 'server2']
	sql_date = time.strftime('%Y'+"-"+'%m'+"-"+'%d
%H'+":"+'%M'+":"+'%S', time.localtime(time1[0]))
	current_date = time.strftime('%Y'+"-"+'%m'+"-"+'%d
%H'+":"+'%M'+":"+'%S', time.localtime(time2[0]))
	file_date = time.strftime('%m'+"_"+'%d'+"_"+'%Y',
time.localtime(time.time()))
	for index in servername:
		dbc = odbc.odbc(index+'/username/password')
		crsr = dbc.cursor()
		for name in familyname:
			crsr.execute("""select * from subtestlist\n\
where (errorcode<>'null'\n\
AND familyname='"""+name+"""'\n\
AND Packagestarttime>'"""+sql_date+"""'\n\
AND Packagestarttime<='"""+current_date+"""');""")
			result = crsr.fetchall()
			for item in range(len(result)):
				data1, data2, data3, data4, data5, data6,
data7, data8, data9, data10, data11, data12, data13, data14, data15, data16,
data17 = result[item]
				data10 = time.ctime(data10)
				data11 = time.ctime(data11)
				result[item] = (data1, data2, data3, data4,
data5, data6, data7, data8, data9, data10, data11, data12, data13, data14,
data15, data16, data17)
			mylist = result[:]
			f = open(index+'_'+name+'_'+file_date+'.txt','a')
			for item in mylist:
				f.write(`item`+'\n')
			f.close()

What this does is connect to a server and pull data from it based on each
family name in the familyname list, using an SQL query.  Conceivably, this
code should connect to server1 and pull data for all familynames and write
that data to a file, server_familyname_date.  Then it should connect to
server2 and do the same.  However, when it connects to server 2, it isn't
pulling the familynames from the familyname list correctly.  Instead, it is
pulling single character strings, like a, b, e, g, h, r, S (these are the
actual strings, which may or may not have some bearing on one of my
familyname entries, I haven't been able to verify).  Has anyone else seen
problem remotely related to this?  Any help is appreciated.

Regards,

Mark Daley





More information about the Python-list mailing list