treasure-data/prestogres — pull request #8 by wyukawa (2014-06-19 04:51:55+00:00)
Title: prestogres works with python 2.6

I try to use prestogres at Centos 6.5.

but, the following error occurs.
```
$ psql -h localhost -p 9900 -U pg postgres
postgres=# SELECT * FROM sys.node;
ERROR: ValueError: zero length field name in format
```

postgres/pg_log/postgresql-[...].log
```
< 2014-06-18 20:43:22.670 JST >ERROR: ValueError: zero length field name in format
< 2014-06-18 20:43:22.670 JST >CONTEXT: Traceback (most recent call last):
PL/Python function "run_presto_as_temp_table", line 3, in
prestogres.run_presto_as_temp_table(server, user, catalog, schema, table_name, query)
PL/Python function "run_presto_as_temp_table", line 202, in run_presto_as_temp_table
PL/Python function "run_presto_as_temp_table", line 124, in _batch_insert
PL/Python function "run_presto_as_temp_table", line 105, in _plan_batch
PL/Python function "run_presto_as_temp_table"
< 2014-06-18 20:43:22.670 JST >STATEMENT: select prestogres_catalog.run_presto_as_temp_table(E'localhost:8080', E'pg', E'hive', E'postgres', E'presto_result', E'SELECT * FROM sys.node limit 1000')
< 2014-06-18 20:43:22.671 JST >ERROR: ValueError: zero length field name in format
< 2014-06-18 20:43:22.671 JST >STATEMENT: do $$ begin raise exception '%', E'ValueError: zero length field name in format' using errcode = E'XX000'; end $$ language plpgsql
```

Default python of Centos 6.5 is python 2.6.

Python 2.6 requires the field numbers(for example, {0}). In Python 2.7 and later, they can be omitted(for example, {}).

ref:http://stackoverflow.com/questions/5446964/valueerror-zero-length-field-name-in-format-error-in-python-3-0-3-1-3-2

So, the following code doesn't work with python 2.6.
```
values_sql_format.append("${}::")
```
https://github.com/treasure-data/prestogres/blob/master/pgsql/prestogres.py#L96

Because I don't know how to work prestogres with python 2.7 and later, I edit prestogres.py to work with python 2.6.

If there is method to work prestogres with python 2.7 and later at CentOS 6.5, this patch is unnecessary.

I setup python 2.7.7 to ~/local/python2.7.7 with xbuild and add PATH, but it doesn't work.