How do I import data from Microsoft Access / SQL Server 2005 into Core Data? - iphone

I am sitting on a ton of data in a SQL Server 2005 database, from which we dump Access databases as a cache.
I want to create an iPhone app based on Core Data that can use this data from my SQL Server 2005 database, or the Access dump.
Based on all of the Core Data tutorials and documentation it appears that I have to use Xcode to create a Core Data schema and populate that schema using Xcode.
SQLite seems like the right thing to act as a dump point, then use SQLite APIs. But this doesn't bridge nicely to Core Data in my mass data scenario.
Apple has obsoleted the SQLite Books Example seemingly with the sole intent of making sure that you use Core Data and not SQLite.
Has anyone come up with a dump scheme for data locked in an Access or SQL Server 2005 DB into an iPhone friendly format? I don't care if it is Mac OS X code, iPhone code, or .NET code... Anything?
In my case I am talking about 26MB of data that I would like to have an offline cache to for my application.
26MB of XML seems like a bad idea. 26MB of SQLite seems like a great idea. 26MB of Core Data seems like an even better idea.
Thanks in advance,
--Batgar

You could create an Objective-C app in XCode using the FreeTDS library to pull data down from your MSSQL database and populate your CoreData store.
http://sourceforge.net/projects/freetds/
There's also a commercial product that provides an MSSQL ODBC driver for Macs, which you could then call from your data migration code:
http://www.actualtechnologies.com/product_sqlserver.php
If that doesn't work, you can set up the MSSQL database with an IIS front-end and retrieve the data using XML queries. Starting with MSSQL 2000, there's a way to query the server directly via HTTP and get back results in XML without having to write any ASP/ASP.NET code.

Related

SQL database in iPhone

I'd like to write an app which use Core Data and need some solution to insert information into my database.
Could I use phpmyadmin for filling the db and then just export to sql or I need another solution?
You could indeed populate an SQLite (note: not SQL) database directly and then use this with Core Data. However, I'd recommend against this, because it may cause maintenance problems down the road when the schema for Core Data's SQLite storage changes under your feet. Consider using Core Data itself to populate the database. And if you do this, you can fairly easily later on change the backing strategy of Core Data from SQLite to something else without incurring lots of work elsewhere.
More discussion:
Populating sqlite db created by CoreData
Any way to pre populate core data?
http://www.raywenderlich.com/980/core-data-tutorial-how-to-preloadimport-existing-data
http://forums.pragprog.com/forums/90/topics/2436
Well, phpMyAdmin is for MySQL and Core Data uses SQLite.
It's possible though. You could export as SQL in phpMyAdmin and replace one or two things to make it compatible with SQLite.
Also, see Christian Kienle's Core Data editor

Import from SQLite manager into a file

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.

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.

how to import sqlite data from firefox add into core data?

I'm new to programming and my app needs a database that will hold about 2000 names which will load into a table and link to a second view showing address, phone, image, links to web site etc.
I have researched cora data and think this is way to go. I have been following the tutorial by ray wenderlich that have been recommended on this site however I don't understand how to contect my sqlite data base to cora data.
http://www.raywenderlich.com/980/core-data-tutorial-how-to-preloadimport-existing-data
more specifically: In the tutorial it states "You can examine the storeUrl variable to see a full path to where the sqlite backing file resides. So find this and copy it to the directory your Python script is in."
I can find the full path to the sqlite file but what is the python script and am I heading in the right direction.
Any help would be great! I have been working on this for days.
AFAIK, you should not manipulate the sqlite database which is used by CoreData directly. The reason for this is that the internal table structure of the CoreData sqlite backend is an implementation detail an not public.
So you are left with two possibilities:
use the standard C sqlite library to import the database into a real CoreData database and then use CoreData with all its bells and whistles. Remember CoreData is not a database.
use the sqlite database as it is and use the APIs available for manipulating and fetching data directly. You could not use CoreData in this case but instead use standard SQL to interact with the database. The benefit is that you do not have to keep two databases, the coreData backend and the external sqlite database in sync.
you can follow this tutorial if you want to get data from your sqlite database
http://dblog.com.au/iphone-development-tutorials/iphone-sdk-tutorial-reading-data-from-a-sqlite-database/
look at -(void) checkAndCreateDatabase to get path.

using SQL Server 2008 instead of SQLite in iPhone

I have created an application that makes use of database.
Can I use SQL Server 2008 in the iPhone to store data instead of SQLite?
Apple does not supply MS SQL server 2008 with IOS and you can't install it as Microsoft does not supply an ARM based version running on IOS. You are stuck with sqlite as the database engine on the iPhone. You can connect to SQL Server running on an external website using SOAP or a RESTFUL inteface.
As has been suggested you can use a web service call to your SQL 2008 database from your iOS application, if you are going to keep the data on the server side.
However, you should investigate Core Data and not use SQLlite if you are going to implement a client-side solution. Core Data is the preferred solution.
If you are familiar with Entity Framework then some of the concepts of Core Data should be easier to follow.
http://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/CoreData/Articles/cdBasics.html#//apple_ref/doc/uid/TP40001650
NO,You can'nt use sql server 2008,
For any DB operation you will have to use sqllite in iPhone.