[reportlab-users] Reportlab problem displaying japanese characters in a table
    Paul Barrass 
    paul.barrass at safeonlinebilling.com
       
    Mon Jun 15 11:37:49 EDT 2009
    
    
  
Michael Dorrian wrote:
>
> for col in JPYRows:
>       firstCol = row[0].decode('shiftjis')
>       secondCol = row[1].decode('shiftjis')
>       ......
>       TenthCol = row[9].decode('shiftjis')
>       table_data = [[firstCol,secondCol....TenthCol]]
This would be slightly better expressed something like:
for row in JPYRows:
    decoded_row=[col.decode('shiftjis') for col in row]
    table_data.append(decoded_row)
which is easier to understand and will work in cases where you don't 
have exactly 10 columns of data....
Something I noticed with Andy's query function:
def query(conn, sql_statement):
   cur = conn.cursor()
   cur.execute(sql_statement)
is there's no way to pass parameters - I'm assuming that the query is 
built up fully in sql_statement, surely it would be better to pass a 
parameter-based query and the parameters, so that the DB API can 
escape/quote the various fields as required, rather than you having to 
remember to do so each time you use the query function or leave yourself 
open to an failed query, or worse an SQL injection attack if user input 
is accepted.
Paul Barrass.
    
    
More information about the reportlab-users
mailing list