title: python - 'str' object has no attribute 'execute'
body: <p>First time python user here, be gentle.... ;-)</p>
  
  <p>Python 2.6 on OSX</p>
  
  <p>Got a class which just has some wrappers around sqlite... here it is</p>
  
  <pre><code>from pysqlite2 import dbapi2 as sqlite
  
  class SqliteDB:
      connection = ''
      curser = ''
  
      def connect(self):
          try:
              self.connection = sqlite.connect("pagespeed.sqlite")
              self.curser = self.connection.cursor()
           except sqlite.Error, e:
              print "Ooops: ", e.args[0]
  
      def find_or_create(self, table, column, value):
          self.curser.execute("SELECT id FROM ? WHERE ?=? LIMIT 1", (table, column, value))
          records = self.curser.fetchall()
          if records.count() == false:
              self.curser.execute("INSERT into ? SET ?=?", (table, column, value))
              self.curser.execute("SELECT id FROM ? WHERE ?=? LIMIT 1", (table, column, value))
          print records
  </code></pre>
  
  <p>and I call it like this in a separate file</p>
  
  <pre><code>import sqlitedb
  
  def main():
      db = sqlitedb.SqliteDB()
      db.connect    
      url_id = db.find_or_create('urls', 'url', 'http://www.example.com')
  </code></pre>
  
  <p>however I get this error, </p>
  
  <pre><code>Traceback (most recent call last):
  
    File "update_urls.py", line 17, in &lt;module&gt;
  
    main()
  
    File "update_urls.py", line 11, in main
  
    url_id = db.find_or_create('urls', 'url', 'http://www.example.com')
  
    File "....../sqlitedb.py", line 16, in find_or_create
  
    self.curser.execute("SELECT id FROM ? WHERE ?=? LIMIT 1", (table, column, value))
  
  AttributeError: 'str' object has no attribute 'execute'
  </code></pre>
  
  <p>So it's almost like self.curser is not getting a curser, or is self not correct?</p>
  
  <p>Not to sure if what I am doing is right here.... </p>
  
  <p>cheers</p>