dmertl.com

iPhone

iPhone SQLite ‘no such table’ error

June 4, 2009 by dmertl 9 Comments

I recently ran into an annoying problem getting data from an SQLite database in my iPhone application. I had bundled the database with the application and duplicated code from Apple’s example code. No matter what I did every time I tried to select from my table I would get “no such table: table_name”. I tried checking what tables existed in the database using “SELECT name FROM sqlite_master WHERE type = ‘table'”, and found there were none.

What happened is sqlite3_open() will create a new database if it can’t find the one you requested. It will also cache this empty database and use it in the simulator. So even though I had fixed the issue with my code, that empty database was still being used. The solution to this is to delete the app from the simulator (click and hold the app icon, then click the x) and re-build. This will clear the cached database and use the copy bundled with your app.

Hopefully this will help someone else avoid a few hours of annoyance. It seems to be a fairly common pitfall, but I wasn’t able to find much in the way of answers.

Posted in: iPhone Tagged: cocoa, iPhone, nosuchtable, programming, sqlite, xcode

Blogroll

  • Antarctica
  • Non-coding stuff
  • Photos
  • Rainbows

Recent Posts

  • Resizing optimized animated GIFs in Photoshop
  • Saving an animated GIF in Photoshop with “combine” instead of “replace” frames
  • Mimicking Django Admin Change Form Styling in a Custom Form
  • Installing custom Plex plugins on a Drobo 5N
  • Bug in CakePHP Containable Behavior, Related Records not Being Returned When Parent Contains a Single Field

Categories

  • CakePHP
  • Canon
  • Django
  • Doctrine
  • iPhone
  • mac
  • Magento
  • MS Access
  • MSSQL
  • Photography
  • Python
  • SQL
  • Uncategorized
  • Zend

Tags

@@IDENTITY adapter authentication breadcrumbs CakePHP Canon cocoa Doctrine email eos utility errors iPhone leopard lost cd mac Magento MS Access MS SQL mysql mysqli nosuchtable os x override parse pdo_mysql.php php programming raw redirect smtp SQL sqlite SQL Server triggers updater validation xcode Zend zend_mail_message

Copyright © 2023 dmertl.com.

Omega WordPress Theme by ThemeHall