Fix format string constructed for query to use tuple instead of list

e.g. '%s%s' % ['a', 'b']
will return "TypeError: not enough arguments for format string"

by changing it to:
'%s%s' % tuple(['a', 'b'])
we will get "ab" as expected

Return results using tuples inside a list like psycopg2, i.e. [(value1,
value2), (value3, value4)]
Use colnames to order the returned result correctly

.colnames was only added in postgresql 9.2.  There is no way to ensure
the order of the columns without it, so skip the test if postgresql is
older than 9.2.
Return values from non select statements too

This includes insert, update and delete statements that contain
"RETURNING".
Directly insert NULL into the query if a variable is None
Get db connection and cursor to work with python "with"
Detect bytea type in py_param_to_pg_type and convert to right format

psycopg2 accepts buffer, memoryview, bytearray and bytes python types as
postgres bytea type.