Import from SQLite manager into a file - iphone

I'm using SQLite version 2.8.17 - 3.3.7 / PHP version 5.2.17
I've created a db with a few tables and want to export it into .db or .sqlite file but it gives me dump text.
I'd like to use this db in iPhone, but I'm currently stuck with app to manage sqlite databases.
Would appreciate any help.
Also I've tried sqlite manager for firefox, but its ugly:)
Please, tell me about an app to create sqlite databases and populate them with info for future use in iPhone.

Have a go with Lita

I use Navicat for SQLite for this. Im my opinion it's a great tool with a nice GUI. You can import/export in several formats. Well, it's not free, but there is a trial.

I have successfully implemented what you're talking about by dumping the database (serverside) into an XML file, which the iPhone can pull via a simple http request, and then convert into it's own data structures. Reading XML on the iPhone.
Originally, I tried doing it how you're thinking, it was just too complicated and error-prone to justify.

Related

Convert parts of mySQL DB from website into CoreData/SQLite on iOS

I have a website with mySQL database, parts of which I'd like to reuse in my iPhone app by populating CoreData DB (basically iPhone app is going to be an offline version of the website).
I am thinking of writing scripts which will translate mySQL into SQLite and then somehow feed the data into CoreData.
How would you accomplish this task?
Solution
Check out the following tutorial:
http://www.raywenderlich.com/980/core-data-tutorial-how-to-preloadimport-existing-data
TL;DR - uses a python script to write to the SQLite database in a Core Data compatible format.
Possible Drawbacks
If you've got a complex database, this could get messy fast.
If there's any errors in the format of the SQLite database, Core Data is not tolerant and you might get unexplained crashes.
Apple recommend that you never mess directly with the data store directly, which makes me a bit nervous of this approach.
Alternative
I'd dump the mySQL database to a CSV file, model the Core Data store in Xcode as unusual and write a quick and dirty importer within the application itself.
You could use cCSVParse to do the CSV heavy lifting.

Any FREE SQLite Manager for MAC OS X?

I am learning Core Data for iPhone application. I defined .xcdatamodel. But I have the following questions:
Is it possible to make .sqlite file
from the .xcdatamodel file ?
If not, what is the correct
procedure to prepare .sqlite ?
If it is necessary to use external
tool, is there any FREE tool to make
.sqlite ?
Thanks.
Your questions 1 & 2 have already been answered but here's a comprehensive overview for Q3:
http://www.barefeetware.com/sqlite/compare/?ch
I personally use a (free) Firefox add-on called SQLite Manager - you can download it from here https://addons.mozilla.org/en-US/firefox/addon/sqlite-manager/
Is it possible to make .sqlite file
from the .xcdatamodel file ?
Well, when you create a Core Data stack and set your store to an SQLite store, the persistent store coordinator will create a .sqlite file configured for the model attached to the store.
If not, what is the correct procedure
to prepare .sqlite ?
Before iOS 3.0, you couldn't use Core Data so there were several libraries out there for using SQLite. However, I don't think any of them have been updated because there is not much point when using Core Data.
If it is necessary to use external
tool, is there any FREE tool to make
.sqlite ?
SQLite comes standard as part of MacOS X so you can use the command line or scripting languages like Ruby, Python, Perl (also standard) to create any SQLite database you want.
But honestly, I wouldn't bother. Unless your app's data is very simple and largely static, you will end up reinventing the wheel and effectively reproducing most of Core Data just to interface SQLite with the rest of the app.
Core Data's SQLite structure really isn't designed to be handled by anything other than Core Data. Even if you have your persistent store use the SQLite data format, if you open it in a generic SQLite tool you're going to get a cryptic mash of nothing-you-can-reliably-mess-with.
I'm guessing your goal is to have pre-populated data in your database? The right way to do that is to write some “importer” code that reads in whatever existing data you have and creates objects in the persistent store corresponding to those. Keep a copy of that persistent store—maybe in your app bundle, to be copied out to a temporary directory for writing—and you've got yourself a starting data set.

Iphone programming- Importing an existing sql table to sqlite or core data

I have a simple table that I'm pulling from our existing sql database. Its just a 1mb Vehicle table. It contains enough information that I don't want to create it from scratch, but I can not find a definitive answer on how to import this table into my sqlite environment on the mac.
I've seen a few posts about python scripts that import to Core Data but I don't think thats the way to go.
The table I saved out as .rpt file. Any direction other than the one I'm traveling would be great.
The most correct (and pretty easy) way to do this is to write a little Mac OS X command line tool program that reads the data from your SQLite database and uses Core Data to load the data into a Core Data persistent store.
That persistent store -- the resulting Core Data schema'd SQLite file -- can be added as a resource to your iOS app project and it'll "just work".
Checkout Christian Kienle's Core Data Editor, which let's you import data from CSV files into Core Data: http://christian-kienle.de/CoreDataEditor
It is also useful after the data is imported for debugging.

Can I synchronize many records from sqlite database from iphone to mysql database on server

Currently I am developing an iPhone app with sqlite database, this database just has only one table with many records. And my server is using MySQL database. I would like to ask:
Can I send many records from sqlite database to MySQL database to update the table in MySQL database. Because I think I can do update with just one record. If you have a solution, please tell me detail how I can do that?
Any help would be appreciated.
Thanks.
As I'm sure you've discovered, there is no built-in solution. There may be frameworks out there to help with it, but I'm unaware of any.
You're best bet is to use some well-known encoding like XML or JSON to transmit the records to the server using HTTP POST, and use Java or PHP or Ruby on Rails or whatever you're comfortable with to capture the record and write it to the database. Of course, once you've done that you need to consider security issues least some Black Hat write a simple perl script to fill your database to bursting with junk. You also need to be able to handle transmission failures and duplicate records. It is a lot of work.
XML parsing is built-in to iOS. JSON parsing can be added with the JSON iPhone framework. This are pieces to the puzzle, but there is still a lot left.

How can I create a sample SQLite DB for my iPhone app?

I'm diving in to iPhone development and I'm building an iPhone app that uses the Core Data framework and my first task will be to get the model setup with a view that will display it. Thus far, I have the model defined and my Managed Object Files created, but I don't have a database with any sample data.
What's a quick way to create a DB that conforms to my schema?
Are there any tools that can generate a sample DB using my schemas? Or do I have to create this sample data by hand?
Once the DB is created, are there any good tools I can use to directly manipulate the data in DB for testing purposes?
Thanks in advance for your help! I'm going to continue researching this question right now.
This is very close to the question "Provide Base Data for Core Data Application?" Additionally, my answer to this question describes how you can quickly build a Mac application that lets you create or edit a Core Data database that is compatible with your iPhone application's data model.
Beyond that, you can use the application Core Data Editor to do what its name describes.
I assume you've already created a working app that uses sqlite as persistent storage for your data model.
Have a look into the AppDelegate.m file to search for the sqlite database name and location, then run your app in the iPhone Simulator.
Use Spotlight to search for the SQLite database created by the app in the simulator, usually this is /Users/<Username>/Library/Application Support/iPhone Simulator/User/Application/<Application GUID>/Documents/<database name.sqlite>
Now you only have to copy that file to a working folder, open it using sqlite3 (www.sqlite.org), then type .schema to retrieve the database schema.
Now populate it, either by hand or using a python/ruby/whatever script!
Unfortunately, i'm not aware of any tool that will populate a db by simply feeding them the schema.
For directly manipulating the data, sqlite3 provides you with a command line utility that's really handy for that purpose.
When you're finished, add the file with sample data to your App project.