# Collection Import AND/OR CLI to import files?

**URL:** <https://discourse.getcockpit.com/t/collection-import-and-or-cli-to-import-files/188>\
**Category:** General\
**Created:** [August 4, 2018, 1:18pm UTC](https://discourse.getcockpit.com/t/collection-import-and-or-cli-to-import-files/188 "2018-08-04T13:18:45Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![kosma](https://avatars.discourse-cdn.com/v4/letter/k/b77776/32.png) [@kosma](https://discourse.getcockpit.com/u/kosma)\
**Post date:** [August 4, 2018, 1:18pm UTC](https://discourse.getcockpit.com/t/collection-import-and-or-cli-to-import-files/188/1 "2018-08-04T13:18:45Z")

</div>

I have some data in json format that can correspond to collection structure, can I import a collection file to cockpit?  
I see that there is import button in assets and in modules/Collections/cli folder there are some import export scripts, but anyone know how to use them?

Are there any CLI commands for cockpit?

---

<div class="post-metadata">

**Author:** ![unenouvelleville](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/unenouvelleville/32/83_2.png) [@unenouvelleville](https://discourse.getcockpit.com/u/unenouvelleville)\
**Post date:** [August 31, 2018, 8:04pm UTC](https://discourse.getcockpit.com/t/collection-import-and-or-cli-to-import-files/188/2 "2018-08-31T20:04:10Z")

</div>

I would love to know, how can I import my data too.

---

<div class="post-metadata">

**Author:** ![kosma](https://avatars.discourse-cdn.com/v4/letter/k/b77776/32.png) [@kosma](https://discourse.getcockpit.com/u/kosma)\
**Post date:** [September 1, 2018, 5:44am UTC](https://discourse.getcockpit.com/t/collection-import-and-or-cli-to-import-files/188/3 "2018-09-01T05:44:24Z")

</div>

I think no-one answered to me because to answer was so obvious and I found it later.  
you can find Import/export in menu that you can see when you hover over collection:

![menu](https://canada1.discourse-cdn.com/flex030/uploads/getcockpit/original/1X/47121983bc1375cb3e1e47cb3aa40a6b9bca3cbd.png)

import it self let you even import relations to other collections (you can filter fields), which is very cool and let you quickly get your data in place.  
But for some reason if you export data and then reimport it with cockpit it cannot make the connectionLink correctly

---

<div class="post-metadata">

**Author:** ![unenouvelleville](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/unenouvelleville/32/83_2.png) [@unenouvelleville](https://discourse.getcockpit.com/u/unenouvelleville)\
**Post date:** [September 1, 2018, 10:45am UTC](https://discourse.getcockpit.com/t/collection-import-and-or-cli-to-import-files/188/4 "2018-09-01T10:45:23Z")

</div>

@kosma  
Thank you for your answer.

but strangely nothing appear when i’m on my collection and when i hover the name.

 ![50](https://canada1.discourse-cdn.com/flex030/uploads/getcockpit/original/1X/0b239f93b3a74cf26ddf3531b32e52d529857db1.png)

so bad ☹

---

<div class="post-metadata">

**Author:** ![serjoscha87](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/serjoscha87/32/151_2.png) [@serjoscha87](https://discourse.getcockpit.com/u/serjoscha87)\
**Post date:** [September 1, 2018, 10:46am UTC](https://discourse.getcockpit.com/t/collection-import-and-or-cli-to-import-files/188/5 "2018-09-01T10:46:51Z")

</div>

> [@unenouvelleville](#):
>
> but strangely nothing appear when i’m on my collection and when i hover the name.

sounds like you are missing the needed access rights to import data - retry it as admin user

---

<div class="post-metadata">

**Author:** ![unenouvelleville](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/unenouvelleville/32/83_2.png) [@unenouvelleville](https://discourse.getcockpit.com/u/unenouvelleville)\
**Post date:** [September 1, 2018, 10:55am UTC](https://discourse.getcockpit.com/t/collection-import-and-or-cli-to-import-files/188/7 "2018-09-01T10:55:11Z")

</div>

Right, we need to be admin!

Is someone know how to transform MySQL database to JSON file?  
I already created a JSON file from my SQL server:

```
places: [

 {
   id: "2",

   structure_id: "2",

   nom: "Allô Candy asbl",

   secteur: "0-3",

   adresse: "9, rue Louis Bréguet",

   codepostal: "6041",

   ville: "Gosselies",

   telephone: "071/45.03.33",

   gsm: "",

   email: "allo-candy.accueil@hotmail.be",

   web: "www.allocandy.be",

   description: "La Crèche d'Allo Candy asbl dispose de 48 places.",

   categorie1: "Structure d'accueil",

   souscat1: "Crèche",

   souscat2: "",

   latitude: "50.47487",

   longitude: "4.47205"},

 { ...
```

---

<div class="post-metadata">

**Author:** ![serjoscha87](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/serjoscha87/32/151_2.png) [@serjoscha87](https://discourse.getcockpit.com/u/serjoscha87)\
**Post date:** [September 1, 2018, 12:26pm UTC](https://discourse.getcockpit.com/t/collection-import-and-or-cli-to-import-files/188/8 "2018-09-01T12:26:22Z")

</div>

just did a quick google search. Try this:

[https://www.csvjson.com/sql2json](https://www.csvjson.com/sql2json)

---

<div class="post-metadata">

**Author:** ![artur](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/artur/32/4_2.png) [@artur](https://discourse.getcockpit.com/u/artur)\
**Post date:** [September 1, 2018, 1:02pm UTC](https://discourse.getcockpit.com/t/collection-import-and-or-cli-to-import-files/188/9 "2018-09-01T13:02:53Z")

</div>

Btw, you can also import csv files ☝️

---

<div class="post-metadata">

**Author:** ![unenouvelleville](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/unenouvelleville/32/83_2.png) [@unenouvelleville](https://discourse.getcockpit.com/u/unenouvelleville)\
**Post date:** [September 3, 2018, 4:05pm UTC](https://discourse.getcockpit.com/t/collection-import-and-or-cli-to-import-files/188/10 "2018-09-03T16:05:50Z")

</div>

Hi,

Actually when we try to import our JSON file, we got this:

 ![16](https://canada1.discourse-cdn.com/flex030/uploads/getcockpit/original/1X/26c2247ae3220b0c7f635e1a15abe6cf4adc639f.png)

and nothing move further.

Do you know why?

Thank you,  
Une Nouvelle Ville ASBL

---

<div class="post-metadata">

**Author:** ![serjoscha87](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/serjoscha87/32/151_2.png) [@serjoscha87](https://discourse.getcockpit.com/u/serjoscha87)\
**Post date:** [September 3, 2018, 4:28pm UTC](https://discourse.getcockpit.com/t/collection-import-and-or-cli-to-import-files/188/11 "2018-09-03T16:28:10Z")

</div>

try pressing Control+Shift+J in order to open the chrome developer console (guessing you are using chrome). Check if there are any console errors when you are trying to import data
