Q:

Is this the smallest non-affine scheme?

Exercise I.XXV. of the book Geometry of Schemes by Eisenbud and Harris claims that the smallest non-affine scheme has three elements with a constructed topology and sheaf. But I am wondering if this is really the smallest non-affine scheme, so I tried with the two-elements example:  

If we define $X=\{p,q\}$ with the discrete topology, and if $\mathscr O(X)=\mathscr O(\{p\})=\mathscr O(\{q\})=\text{ a field } K$ while $\mathscr O(\phi)=\{0\}$, and the restrictions are either identity or the obvious map, then $X$ is covered by affine schemes, so the pair $(X,\mathscr O)$ forms a scheme, but is obviously not affine.  

So is the above constructed scheme the smallest non-affine one, as intended?
Any inappropriate point ought to be localised, and thanks in advance.  

A:

The problem is that your structure sheaf is easily seen to not be a sheaf. 
Let $k_1,k_2\in K$ thought of as sections over $\{p\}$ and $\{q\}$ then since $\{p\},\{q\}$ is an open cover for $X$ and clearly the sections $k_1$ and $k_2$ agree on overlaps, so there exists $k\in \mathscr O(X)$ with $\rho_{X\rightarrow\{p\}}(k)=k_1$ and $\rho_{X\rightarrow\{q\}}(k)=k_2$. But by picking another $k_3 \in \mathscr O(\{p\})$ we can show $\rho_{X\rightarrow\{q\}}$ is not injective, which is a contradiction since it is a morphism from a field.
Given any two-point discrete scheme (any not discrete scheme has only trivial open covers so is affine) , we can see $\mathscr O(\{p\})=\mathscr O_p$ for each $p$. So, $\mathscr O(\{p\})$ is local. Consider the map $\phi :\mathscr O(\{p\})\times \mathscr O(\{q\}) \rightarrow \mathscr O(X)$. Where $\phi(r,s)$ is the unique section of $\mathscr O(X)$ that restricts to $r$ and $s$ respectively on $\mathscr O(\{p\})$ and $\mathscr O(\{q\})$, (note this section exists and is unique by the sheaf property). This map is clearly a ring morphism and injective (and well defined by uniqueness of the section), it is clearly surjective as well as any global section $s$ restricts to $r_1  \in \mathscr O(\{p\})$ and $r_2\in  \mathscr O(\{q\})$. By definition $\phi(r_1,r_2)=s$ so we are done. So any two-point scheme is affine. It is trivial to show any one-point scheme is affine. So the smallest non-affine scheme has three points.
This argument together with some induction shows $$\bigsqcup_{i=1}^n\operatorname{Spec} R_i\cong \operatorname{Spec} \prod_{i=1}^n R_i$$ which should not be that surprising. What is truly surprising is that this fails for any infinite cardinal as
$\bigsqcup_{i=1}^\infty\operatorname{Spec} R_i$ is not quasicompact but $\operatorname{Spec}\prod_{i=1}^n R_i$ is.

