Project

General

Profile

« Previous | Next » 

Revision 1922

csv2ddl: Renamed schema name env var from datasrc to schema to reflect what it is, and to make the script general beyond importing inputs

View differences:

csv2ddl
22 22
            +' <header >ddl')
23 23
    
24 24
    # Get config from env vars
25
    datasrc = opts.get_env_var('datasrc', None, env_names)
25
    schema = opts.get_env_var('schema', None, env_names)
26 26
    table = opts.get_env_var('table', None, env_names)
27
    if datasrc == None or table == None: usage_err()
27
    if schema == None or table == None: usage_err()
28 28
    
29 29
    # Get col names
30 30
    reader, col_names = csvs.reader_and_header(sys.stdin)
31 31
    
32 32
    # Write CREATE TABLE statement
33 33
    out = sys.stdout
34
    out.write('CREATE TABLE '+esc_name(datasrc)+'.'+esc_name(table)+' (\n')
34
    out.write('CREATE TABLE '+esc_name(schema)+'.'+esc_name(table)+' (\n')
35 35
    out.write('row_num serial NOT NULL\n')
36 36
    for col_name in col_names: out.write(', '+esc_name(col_name)+' text\n')
37 37
    out.write(');\n')

Also available in: Unified diff