<s> from django . core . management . base import NoArgsCommand <EOL> import pgdb <EOL> from settings import * <EOL> import csv <EOL> def generate_csvs ( num_pages = None ) : <EOL> """<STR_LIT>""" <EOL> conn = pgdb . connect ( host = PG_HOST , user = PG_USER , password = PG_PASSWORD , database = PG_DATABASE ) <EOL> for fy in FISCAL_YEARS : <EOL> print "<STR_LIT>" % fy <EOL> sql = "<STR_LIT>" % ( '<STR_LIT:U+002C>' . join ( CANONICAL_FIELD_ORDER ) , PG_TABLE_NAME , fy ) <EOL> cursor = conn . cursor ( ) <EOL> cursor . execute ( sql ) <EOL> print "<STR_LIT>" <EOL> f = open ( '<STR_LIT>' % ( fy ) , '<STR_LIT:w>' ) <EOL> writer = csv . writer ( f ) <EOL> n = <NUM_LIT:0> <EOL> p = <NUM_LIT:0> <EOL> while True : <EOL> row = cursor . fetchone ( ) <EOL> print "<STR_LIT>" <EOL> if row is None : <EOL> break <EOL> writer . writerow ( row ) <EOL> n += <NUM_LIT:1> <EOL> f . close ( ) <EOL> class Command ( NoArgsCommand ) : <EOL> help = "<STR_LIT>" <EOL> def handle_noargs ( self , ** options ) : <EOL> generate_csvs ( num_pages = <NUM_LIT:1> ) </s>
