Vaibhav Verma
Vaibhav Verma

Reputation: 1037

Import Data to Realm Database

I want to use a centralized database and am looking at various options to do so. From my understanding, I have three main options: SQLite, Realm, and CoreData. Are these options fine for a large centralized database for all users.

Additionally, I am trying to import data from JSON and CSV into a Realm database. Does Realm have this functionality?

Upvotes: 0

Views: 4812

Answers (4)

Murat Yasar
Murat Yasar

Reputation: 1044

As of now, Realm Studio does have the import functionality from CSV.

Open the Realm Studio, File -> Create Realm from -> CSV

enter image description here

Cheers,

Murat

Upvotes: 0

ast
ast

Reputation: 526

I am trying to import data from JSON and CSV into a Realm database. Does Realm have this functionality?

With Realm Cocoa Converter you can import CSV, XLSX, and JSON, and export CSV data. Though, at the moment, it only supports OS X.

Upvotes: 0

Goodlife
Goodlife

Reputation: 3922

public String composeJsonFromRealm(){
        ArrayList<HashMap<String, String>> wordList;
        wordList = new ArrayList<HashMap<String, String>>();
       // Build the query looking at all users:
        // Execute the query:
        RealmResults<User> users = realm.where(User.class).findAll();

        if (users.size()>0){
                User user = users.first();
                HashMap<String, String> map = new HashMap<String, String>();
                map.put("name", user.getName());
                map.put("email",user.getEmail());
                wordList.add(map);


        }

        Gson gson = new GsonBuilder().create();

        return gson.toJson(wordList);

    }

Upvotes: 0

Rashwan L
Rashwan L

Reputation: 38833

As for now Realm does not seem to have the import functionality that you need. Check this thread for more information.

Realm does have a great documentation that you can read at Realm and for SQLite there is this framework (there are for sure more out there) and they both support Swift 2.x. You have to check what suits your requests most.

I can also recommend you to read this database thread at reddit.

Upvotes: 1

Related Questions