Producing sugar from photosynthetic bacteria