import / export just a collection, not entire database

452 views
Skip to first unread message

Karl Cassar

unread,
Apr 23, 2013, 8:38:06 AM4/23/13
to rav...@googlegroups.com
Is it possible to import / export just a set of collection, rather than the whole database?

I have a local db, which I would like to export the data of a collection, and import it in a different database without actually changing the other data.  Is it possible?

Regards,
Karl

Oren Eini (Ayende Rahien)

unread,
Apr 23, 2013, 8:41:14 AM4/23/13
to ravendb


--
You received this message because you are subscribed to the Google Groups "ravendb" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Karl Cassar

unread,
Apr 23, 2013, 8:55:14 AM4/23/13
to rav...@googlegroups.com
I am using v2.0 - Is it possible using v2?  And in v2.5, is it possible via the management studio or only by code?

Regards,
Karl

Fitzchak Yitzchaki

unread,
Apr 23, 2013, 11:06:49 AM4/23/13
to <ravendb@googlegroups.com>
This is not part of 2.0. You can do that by code only, but it may be a good feature to add, to be able to do so from the UI.
Please open a feature request for this.


--

Karl Cassar

unread,
Apr 23, 2013, 11:30:56 AM4/23/13
to rav...@googlegroups.com
Sorry if this may sound dumb, but from where do I open a feature request?

As a side note - I did manage to do this via the CSV Export / CSV Import, but it was quite tedious.  Also, when importing from a CSV the name seems to be the plural version of the csv file. In my case, it was named 'SectionData.csv', and the result collection was 'SectionDatas'.  However, IDs are fine, e.g SectionData/45.  Are there any implications?

Regards,

Karl Cassar, B. Sc. I.T. (Hons) (Melit.)
Technical Director

CasaSoft Ltd., 6, Spencer Flats, Flat 4, Triq Dun Gorg Preca, Hamrun, HMR 1605, Malta (Europe) | View Map View Map

Tel: (+356) 2166 2204 | Mob: (+356) 7979 2211 | Email: ka...@casasoft.com.mt | Web: www.casasoft.com.mt

Skype: Call us on Skype karl.casasoft | CasaSoft on Facebook | CasaSoft on Twitter | CasaSoft on LinkedIn

CasaSoft | Advanced Web Applications, Design & Development
Be Earth-friendly, please do not print this e-mail unless there is truly a need. CasaSoft on LinkedIn
This email message (including attachments) contains information which may be confidential and/or legally privileged. Unless you are the intended recipient, you may not use, copy or disclose to anyone the message or any information contained in the message or from any attachments that were sent with this email, and If you have received this email message in error, please advise the sender by email, and delete the message. Unauthorised disclosure and/or use of information contained in this email may result in civil and criminal liability.
 


--
You received this message because you are subscribed to a topic in the Google Groups "ravendb" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ravendb/o-XIf1ivKFQ/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to ravendb+u...@googlegroups.com.

Karl Cassar

unread,
Apr 23, 2013, 12:15:51 PM4/23/13
to rav...@googlegroups.com
Just noticed there is an issue with the CSV import - null values are inserted as "null" (string), not as null.

Can one insert a null value via CSV?

Regards,
Karl
Message has been deleted

Karl Cassar

unread,
Apr 23, 2013, 3:27:50 PM4/23/13
to rav...@googlegroups.com
The problem isn't just that.  Even for example 'false', it is entered as "false" (string), not the bool (false).

This is only for the 'root' properties, and any nested objects work fine.  

Attached you can find a sample CSV file which for example should have "SectionData.Name = null" for item SectionData/2.  

Regards,
Karl
SectionData-error.csv

Chris Marisic

unread,
Apr 23, 2013, 3:50:15 PM4/23/13
to rav...@googlegroups.com
That i'm not sure what raven could specifically do for you other than perhaps handling a few very specific types like string, bool and numbers. The main issue is since the storage is schemaless there's not really anyway for raven to understand whether a field is true vs "true"
Message has been deleted

Mircea Chirea

unread,
Apr 23, 2013, 5:03:25 PM4/23/13
to rav...@googlegroups.com
Sure there is, if it's a string include two sets of quotes in the CSV; otherwise it's a primitive type. For example:

""some string"","true","5"

Kijana Woodard

unread,
Apr 23, 2013, 5:30:24 PM4/23/13
to rav...@googlegroups.com
Meh. I just hit nuget for kbcsv and nlog and rolled a loop to do read my file. Now it's easy to do whatever.

In my case, I had values like "123,3244,542" which is a csv of ids within a csv (third party format - so i couldn't change it anyway). :-)

Karl Cassar

unread,
Apr 24, 2013, 4:40:36 AM4/24/13
to rav...@googlegroups.com
Yes, I agree with Mircea - If it's a string, include a set of quotes. If not, it's a primitive type.  This does work for objects (not primitive type) which are stored as json, e.g having a column:

Parent
---------
{ Featured: true, Name: "Test Node" }    (this is stored as an object 'Parent', with two properties Featured = true (bool), and Name = "Test Node" (string)

It doesn't work when it's a 'root' property, e.g:

IsFeatured
----------------
false       (this is stored as string)

Or maybe a flag could be introduced to the importer - 'Treat fields not surrounded by quotes as primitive types".  If this is not-ticked, it would do exactly like it is doing now - If it is ticked, it would convert them to primitive types.

Regards,


Karl

Fitzchak Yitzchaki

unread,
Apr 24, 2013, 4:50:17 AM4/24/13
to <ravendb@googlegroups.com>
All the point of CSV import is to give you a nice way to get started with existing data. 
In your case, the workflow that is needed:

1. Import from CSV. 
2. Create a console app, with the CVS items model.
3. Query the existing items and generate a new once based on them. Here you can convert "bool" to bool.
4. Delete the imported CSV files.

The issue with what you have proposed is that requiring each string to be surrounded by "" makes working with the most existing CSV, which typically converted from excel files, difficult. 


--

greg

unread,
Apr 24, 2013, 5:14:14 AM4/24/13
to rav...@googlegroups.com
 
my latest blog post show you how to do that - cant get to it from work but try http://gregorsuttie.com

Karl Cassar

unread,
Apr 24, 2013, 5:52:49 AM4/24/13
to rav...@googlegroups.com
Thanks a lot Greg!  Wish I knew this yesterday - that works pefectly! And there's no need for the import/export CSV issues as I was actually trying to use the CSV functionality to export/import just one collection.

Regards,
Karl

Chris Marisic

unread,
Apr 25, 2013, 1:22:43 PM4/25/13
to rav...@googlegroups.com
The CSV format is actually a very deep and complex file format.
Reply all
Reply to author
Forward
0 new messages