-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Import/Export Support #2880
Comments
Yes, this is definitely something we want to add, however we prioritise fixing features that doesn't have work-arounds currently, and import/export is something that should be possible using our existing API's. Although I fully agree it would be nicer if Realm had API's in place for making it easier. One thing to keep in mind is that Realm is an Object Store which means that the data might not be immediate serialisable into tabular form, e.g. what should we do with circular references. Most likely we will make up "fake" keys for all objects, but it needs to be discussed first. |
waiting...... |
Still waiting.... And how i can import a big table in CSV file to my .realm database? |
Sorry we don't have a timeframe yet. |
@cmelchior We have been successful at exporting the realm database as csv or .realm but we feel like there may be some issues with the workaround as some people report the file is sometimes empty when there should be data. One thing we have not yet figured out is importing as an example csv into the realm database. If at the very least Realm could produce an example on importing workaround that would probably be very helpful for all the devs using it right now. |
@cmelchior Any update on this? |
I assume you just need to read the CSV into an unmanaged RealmObject and insert that into your DB in a transaction, just like you would with any batch inserts from any data source, including REST APIs. |
Would prefer official support like other databases offer |
Why is this feature taking so long? Is there a reason not to support it? |
Mostly because it doesn't have a high priority, compared to other features on our list. |
I think realm should atleast have a documentation page on how one can implement import/export on their own. This is a much needed feature for any database. |
Worst case scenario it is possible using the DynamicRealm API |
any update on this? I need to use this feature in my android application.. |
Honestly guys, I'm not even sure what you guys need here :D But supposedly realm studio can import CSV, I'm a bit confused by how to actually set up the schema though with it, seems to think everything is a string |
Any update on this feature? ETA? |
I support the backend of a mobile application. The apps teams for android and ios use realm. My interest in this is for when something goes wrong and a user needs to export their data from their phone. I load their exported realm db up in realm browser then manually compare with our data on the backend. I want to be able to automate that task. I'm sure there are many reasons for a programatic export of data from realm. The closed nature of realm and your unwillingness to make something like this a priority makes me want to move away from this technology and recommend other things. |
@RohitSurwase what exactly do you need? As I said, people are like +1 but what do they need? What is their goal? What format to what format? How do they intend to preserve the links of objects without primary keys? How do they intend to portray links in CSV??? |
@Zhuinden My requirement is very basic, all I need is .realm file to any lighter readable file format (like .csv). Additionally, even if the exported file could not maintain the relationship without primary IDs, I would manage with that. |
Do you need to do this on Android or on Windows or also on Mac? Although I think on Android that should be easy with the DynamicRealm API, excluding links because that sounds hard |
@Zhuinden For Android. I'll also look into DynamicRealm API. |
@RohitSurwase Actually I started writing it but are you supposed to create a CSV per each table? I assume so because of how you can't really do it any other way, right? |
@Zhuinden Yes, I want to create CSV per each table. Is there any API/function to export a table to CSV in Realm? |
@cmelchior what would it take to get official import and export support? All major android databases offer it. We made a workaround for export but it isn't pretty and importing is still almost impossible. |
@cmelchior Is that export workaround publicly available? Can you please provide a link to do so? Let me check if it fits my use case. |
Realm Studio does have an import/export feature that you can use, but that obviously wouldn't work programmatically in an app, which I assume you are requesting? This is a feature that is very well suited for anyone to take on by using the public dynamic API zhuinden referred to. It doesn't really require any knowledge of Realm implementation details. It can be implemented using just public APIs. There are however details and compromises that need to be considered about what exactly is needed in particular with relationships. |
I am not aware of this, can you show an example API? I mean, Stack Overflow shows that for SQLite, people also wrote their own export function: https://stackoverflow.com/a/47464560/2413303 On that level, it is possible with Realm's APIs. Importing is tricky because CSV won't show relationships. You have an object graph and not just foreign keys. But that's why there is no overhead of JOIN. |
This is never gonna happen, right? :/ |
@hernangonzalez probably not, no I really am not sure how you'd do the relationships in the CSV. Unless you "add foreign keys" to the exported file, but you can't really do that without internals (object id) for relations to RealmObjects that have no primary key. |
seems like realm-cocoa-converter just exports into multiple cvs files (per object). Would that also work for you? |
Goal
We would like to more easily be able to export data from a realm database and import it in. Right now realm does not have any official import/export support like other databases do.
Basically something like this would be nice https://github.com/realm/realm-cocoa-converter or baked right into realm. Right now its hard to get data in and out of realm in formats other than .realm which is proprietary and not very portable.
In order to export more easily to formats like CSV, XLS, PDF we will need this support added
Expected Results
Easy data import/export in multiple formats
The text was updated successfully, but these errors were encountered: