#!/usr/local/bin/jython
#encoding: utf-8
from java.lang import *
from java.sql import *
import jxl.Workbook as jxlWB
from org.apache.poi.hssf.usermodel import *
import os
from org.apache.poi.poifs.filesystem import *
from org.apache.poi.hssf.util import *
from org.apache.poi.hssf.usermodel import *
import jxl.demo
import csv
from pyExcelerator import *
voyage = []
def ecrirfic():
k = row['Compte']
v ='.csv'
fichier = '%s%s' % (k, v)
try:
g=open(fichier,'w')
g.writelines('AGENCE;ville;Code_tiers\n')
g.writelines([toStr2(o)+'\n' for o in voyage])
finally:
g.close()
return fichier
toStr2=lambda o: str(o['AGENCE'])+';'+ str(o['ville'])+';'+ str(o['Code_tiers'] )
def rqt2(tab1, tab2):
sql2 = 'SELECT EXDCARJ , EXDK2DGDE ,EXDCOQY FROM PROD.EXPMODTT where exdcarj = %i and exdcoqy = %i ' %(tab1,tab2)
rs2 = stmt.executeQuery(sql2)
while (rs2.next()):
row2={}
row2['AGENCE']=rs2.getInt(1)
row2['Ville']=rs2.getString(2)
row2['Code_tiers']=rs2.getString(3)
rs2.close()
ecrirfic()
# load DB2 JDBC type 2 driver (app driver)
Class.forName("com.ibm.as400.access.AS400JDBCDriver").newInstance()
con = DriverManager.getConnection( 'jdbc:as400://10.33.X.X','XXXX','XXXXX')
stmt = con.createStatement()
sql1='select * from joel.teleb'
rs = stmt.executeQuery(sql1)
employeeList=[]
while (rs.next()):
row={}
row['Agence']=rs.getInt(1)
row['Compte']=rs.getInt(2)
row['mail']=rs.getString(3)
employeeList.append(row)
rqt2(row['Agence'],row['Ville'])
rs.close()
Partager