title: prepared statements in luasql.postgres
body: <p>I'm trying to follow the example of using prepared statements in luasql found here: 
  <a href="http://lists.luaforge.net/pipermail/kepler-project/2008-January/002207.html" rel="nofollow">http://lists.luaforge.net/pipermail/kepler-project/2008-January/002207.html</a></p>
  
  <p>I have luasql version 2.2.0 installed. </p>
  
  <p>When I try the example code, I get the following error message: </p>
  
  <blockquote>
    <p>lua: postgrestest.lua:63: attempt to call method 'gettypes' (a nil
    value) stack traceback:
            postgrestest.lua:63: in main chunk
            [C]: ?</p>
  </blockquote>
  
  <p>Here's the code: </p>
  
  <pre class="lang-lua prettyprint-override"><code>require "luasql.postgres"
  local databasename = "test"
  local databaseUser = "user"
  local databasepassword = "password"
  local databaseserver="10.10.10.10" -- only rqd for remote database servers.
  --local databaseserver="127.0.0.1"
  local databaseport = 5432 -- only rqd for remote database servers.
  
  env = assert (luasql.postgres())
  con = assert (env:connect(databasename, databaseUser, databasepassword, databaseserver))
  
  -- DROP ANY EXISTING PEOPLE TABLE
  -- note:  con:execute() Returns: a cursor object if there are results, or the number of rows affected by the command otherwise.
  res = con:execute("DROP TABLE people")
  
  -- RECREATE PEOPLE TABLE
  res = assert (con:execute[[
      CREATE TABLE people(
          id integer,
          fname text,
          lname text,
          job text
      )
  ]])
  print ('result from create table is:'..res)
  -- ADD SOME PEOPLE TO THE PEOPLE TABLE
  res = assert(con:execute("INSERT INTO people " ..
      "VALUES (1, 'Roberto', 'Ierusalimschy', 'Programmer')"), "record inserted")
  print ("result from insert"..res)
  
  res = assert(con:execute("INSERT INTO people " ..
      "VALUES (3, 'Taylor', 'Swift', 'Singer')"))
  
  -- RETRIEVE THE PEOPLE TABLE SORTED BY LAST NAME INTO CURSOR
  cur = assert (con:execute"SELECT * from people order by lname")
  
  -- LOOP THROUGH THE CURSOR AND PRINT
  print()
  print(string.format("%15s  %-15s %-15s %-15s",
      "#", "FNAME", "LNAME", "JOB"))
  print(string.format("%15s  %-15s %-15s %-15s",
      "-", "-----", "-----", "---"))
  row = cur:fetch ({}, "a")
  while row do
      print(string.format("%15d  %-15s %-15s %-15s",
          row.id, row.fname, row.lname, row.job))
      row = cur:fetch (row, "a")
  end
  print()
  
  -- prepared statements 
  types = con:gettypes()
  stmt, err = con:prepare("select * from people where lname=$1", types["text"])
  if err then
      print("problems creating prepared statement"..err)
  else
      cur, err = stmt:execute("Swift")
    if err then
          print("Couldn't execute the statement: "..err);
      else
          results = cur:fetch({}, "a")
          while results do
              print(results.id)
          end
      end
  end 
  -- CLOSE EVERYTHING
  cur:close()
  con:close()
  env:close()
  </code></pre>
  
  <p>I've also tried to change the prepare statement to look like this instead: </p>
  
  <pre><code>--types = con:gettypes()
  --stmt, err = con:prepare("select * from people where lname=$1", types["text"])
  stmt, err = con:prepare("select * from people where lname=$1", "Swift")
  if err then
      print("problems creating prepared statement"..err)
  else
      --cur, err = stmt:execute("Swift")
      cur, err = stmt:execute()
    if err then
          print("Couldn't execute the statement: "..err);
  </code></pre>
  
  <p>But I get the same error message, except with the prepare method: </p>
  
  <pre><code>lua: postgrestest.lua:65: attempt to call method 'prepare' (a nil value)
  stack traceback:
          postgrestest.lua:65: in main chunk
          [C]: ?
  </code></pre>
  
  <p>Can you tell me what I'm doing wrong/ how to troubleshoot this?  Thanks!</p>
  
  <p><strong>EDIT 1</strong></p>
  
  <p>The connection to the database and all other code works.  The code that loops through the table and prints the data works. </p>
  
  <p>Thanks. </p>