# migrate sqlite to mysql

**URL:** https://discourse.orthanc-server.org/t/migrate-sqlite-to-mysql/2810
**Category:** Google Groups archive
**Created:** [February 21, 2022, 10:59pm UTC](https://discourse.orthanc-server.org/t/migrate-sqlite-to-mysql/2810 "2022-02-21T22:59:17Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Ricardo\_Silva](https://discourse.orthanc-server.org/letter_avatar_proxy/v4/letter/r/59ef9b/32.png) [@Ricardo\_Silva](https://discourse.orthanc-server.org/u/Ricardo_Silva)
#### Post date: [February 21, 2022, 10:59pm UTC](https://discourse.orthanc-server.org/t/migrate-sqlite-to-mysql/2810/1 "2022-02-21T22:59:17Z")

</div>

Hello,

I have Windows 10 and I have a default installed version of Orthanc 21.9.2 from OSIMIS.

I want to migrate the database from SQLite to mySQL from an older version 20.4.1.

I ran the command: Orthanc.exe c:/Orthanc/ --upgrade and it says that is nothing to update.

So I create a script in PHP that migrate all data from sqlite to mysql and it was all moved.

I was in mysql.json and the config is:  
{  
“MySQL” : {  
“EnableIndex” : true,  
//It’s false because the files are stored in DISK (network drive)  
“EnableStorage” : false,

“Host” : “localhost”,  
“Port” : 3306,  
“Database” : “orthanc”,  
“Username” : “root”,  
“Password” : “the\_password\_of\_course”,

“Lock” : false  
}  
}

In orthanc.json i have:  
“StorageDirectory” : “\\10.10.1.251\Public\TAC”,  
“IndexDirectory” : “\\10.10.1.251\Public\TAC”,

When i go to localhost:8042, I can’t see the records. Database seems to be empty.

What i’m doing wrong?

Regards,  
Ricardo Silva

---

<div class="post-metadata">

### Author: ![jodogne](https://discourse.orthanc-server.org/user_avatar/discourse.orthanc-server.org/jodogne/32/1511_2.png) [@jodogne](https://discourse.orthanc-server.org/u/jodogne)
#### Post date: [February 22, 2022, 7:43am UTC](https://discourse.orthanc-server.org/t/migrate-sqlite-to-mysql/2810/2 "2022-02-22T07:43:38Z")

</div>

Hello,

You have to replicate from your old instance of Orthanc running SQLite, to your new instance of Orthanc running MySQL. This is explained in the Orthanc Book:  
[https://book.orthanc-server.com/users/replication.html](https://book.orthanc-server.com/users/replication.html)

HTH,

Sébastien-

---

<div class="post-metadata">

### Author: ![Ricardo\_Silva](https://discourse.orthanc-server.org/letter_avatar_proxy/v4/letter/r/59ef9b/32.png) [@Ricardo\_Silva](https://discourse.orthanc-server.org/u/Ricardo_Silva)
#### Post date: [February 22, 2022, 5:18pm UTC](https://discourse.orthanc-server.org/t/migrate-sqlite-to-mysql/2810/3 "2022-02-22T17:18:48Z")

</div>

Thanks Sebastian,

But i’m a little bit newbie and I don’t Understand how the flow is working.

So, as I understand I should do something like this:

- Stop services (I don’t need to update database);
- change mysql.json to “EnableIndex” : true, (AND) “EnableStorage” : false, (because I don’t want store DICOM on Database) and of course login to mysql database;
- create manually database called “orthanc” on mysql;
- Start service (The tables, procedures, indexes, etc. will be created automatically)
- Stop service again;
- I downloaded file ImportDicomFiles.py to C:\Program Files\Orthanc Server and execute python like this:

PS C:\Program Files\Orthanc Server\> python.exe ImportDicomFiles.py 192.168.0.2 8042 OrthancStorage

SUCCESS: 0 DICOM file(s) have been successfully imported

I tried with localhost:  
PS C:\Program Files\Orthanc Server\> python.exe ImportDicomFiles.py 127.0.0.1 8042 OrthancStorage

SUCCESS: 0 DICOM file(s) have been successfully imported

I tried with service turned on and the same info.

My localnetwork is: 10.10.1.0/24 (not 192.168.0/24). It does metter for API REST?  
My Storage files is in the network on: \10.10.1.251\Public\TAC as well as index

What i’m doing wrong?

Thanks in advance.

A terça-feira, 22 de fevereiro de 2022 à(s) 07:43:38 UTC, [s.jo...@gmail.com](mailto:s.jo...@gmail.com) escreveu:

---

<div class="post-metadata">

### Author: ![Alain\_Mazy](https://discourse.orthanc-server.org/letter_avatar_proxy/v4/letter/a/9de053/32.png) [@Alain\_Mazy](https://discourse.orthanc-server.org/u/Alain_Mazy)
#### Post date: [February 23, 2022, 8:20am UTC](https://discourse.orthanc-server.org/t/migrate-sqlite-to-mysql/2810/4 "2022-02-23T08:20:39Z")

</div>

Hi Ricardo,

During your upgrade from SQLite to MySQL, you will actually need 2 times the storage because the DICOM files from your initial SQLite Orthanc will have to be imported to the new storage of your MySQL Orthanc.

So, you should probably:

- rename \10.10.1.251\Public\TAC into \10.10.1.251\Public\oldTAC
- Create a new \10.10.1.251\Public\TAC folder
- start the new MySQL Orthanc that will be empty and pointing to \10.10.1.251\Public\TAC
- launch the import script pointing to your old DICOM files: python.exe ImportDicomFiles.py 192.168.0.2 8042 \10.10.1.251\Public\oldTAC

Note that I don’t know how the import script will behave wrt to your network storage \10.10.1.251\Public\oldTAC, you might need to map it to a windows drive (e.g D:) to make it work

HTH,

Alain

---

<div class="post-metadata">

### Author: ![Ricardo\_Silva](https://discourse.orthanc-server.org/letter_avatar_proxy/v4/letter/r/59ef9b/32.png) [@Ricardo\_Silva](https://discourse.orthanc-server.org/u/Ricardo_Silva)
#### Post date: [February 23, 2022, 11:30am UTC](https://discourse.orthanc-server.org/t/migrate-sqlite-to-mysql/2810/5 "2022-02-23T11:30:17Z")

</div>

Tahnk you Alain,

I made your suggestion but it doesn’t work:

1. I rename TAC into oldTAC
2. I created a new TAC
3. I deleted mysql database “orthanc” and create new one, and start service.
4. I stop service
5. I’ve mapped with command: net use Z: \10.10.1.251\Public /User:support (NOTE: I have the same user/password in Windows, NAS QNAP and in Orthanc Service).
6. I tried both:  
python.exe ImportDicomFiles.py 192.168.0.2 8042 \10.10.1.251\Public\oldTAC  
python.exe ImportDicomFiles.py 192.168.0.2 8042 Z:\oldTAC

Both gaves me the same error:  
PS C:\Users\support\> python.exe ImportDicomFiles.py 192.168.0.2 8042 Z:\oldTAC  
[WinError 10060] Uma tentativa de ligação falhou porque o componente ligado não respondeu  
corretamente após um período de tempo, ou a ligação estabelecida falhou  
porque o anfitrião ligado não respondeuImporting Z:\oldTAC\index =\> unable to connect (Is Orthanc running? Is there a password?)  
[WinError 10060] Uma tentativa de ligação falhou porque o componente ligado não respondeu  
corretamente após um período de tempo, ou a ligação estabelecida falhou  
porque o anfitrião ligado não respondeuImporting Z:\oldTAC\index.7z =\> unable to connect (Is Orthanc running? Is there a password?)  
[WinError 10060] Uma tentativa de ligação falhou porque o componente ligado não respondeu  
corretamente após um período de tempo, ou a ligação estabelecida falhou  
porque o anfitrião ligado não respondeuImporting Z:\oldTAC\00\00\00001ad2-7c7d-4478-a4c6-18c0d5aa52a8 =\> unable to connect (Is Orthanc running? Is there a password?)  
Importing Z:\oldTAC\00\00\00002291-48ab-406f-b165-6d990cf8d856 =\> ignored JSON file  
Importing Z:\oldTAC\00\00\00002a34-e6de-4da0-92c9-761b941523ff =\> ignored JSON file  
Importing Z:\oldTAC\00\00\00003f6c-d7ee-4238-9dc8-ce3bae845c7c =\> ignored JSON file  
[WinError 10060] Uma tentativa de ligação falhou porque o componente ligado não respondeu  
corretamente após um período de tempo, ou a ligação estabelecida falhou  
porque o anfitrião ligado não respondeuImporting Z:\oldTAC\00\00\00005b03-bf5e-41b8-8d40-8c39b9a93830 =\> unable to connect (Is Orthanc running? Is there a password?)

I’ve tried with service running and stopped and get the same errors.

Can you help me please?

Thanks in advance.  
Ricardo Silva

A quarta-feira, 23 de fevereiro de 2022 à(s) 08:20:53 UTC, [alain.maz...@gmail.com](mailto:alain.maz...@gmail.com) escreveu:

---

<div class="post-metadata">

### Author: ![Alain\_Mazy](https://discourse.orthanc-server.org/letter_avatar_proxy/v4/letter/a/9de053/32.png) [@Alain\_Mazy](https://discourse.orthanc-server.org/u/Alain_Mazy)
#### Post date: [February 23, 2022, 1:37pm UTC](https://discourse.orthanc-server.org/t/migrate-sqlite-to-mysql/2810/6 "2022-02-23T13:37:26Z")

</div>

Sorry, you probably need to change the IP address by the one where Orthanc is running (probably localhost or 127.0.0.1)

---

<div class="post-metadata">

### Author: ![Ricardo\_Silva](https://discourse.orthanc-server.org/letter_avatar_proxy/v4/letter/r/59ef9b/32.png) [@Ricardo\_Silva](https://discourse.orthanc-server.org/u/Ricardo_Silva)
#### Post date: [February 23, 2022, 3:00pm UTC](https://discourse.orthanc-server.org/t/migrate-sqlite-to-mysql/2810/7 "2022-02-23T15:00:52Z")

</div>

Thanks,

I think it works. Now it’s importing but sometimes says “ignored JSON file”, like this:

…  
Importing Z:\oldTAC\00\00\0000f462-183e-47e0-8045-d09aa7a42f8b =\> ignored JSON file  
Importing Z:\oldTAC\00\01\000100c5-c48a-4e9d-a0e2-f5c78c26704d =\> success  
Importing Z:\oldTAC\00\01\00010d07-b389-4837-9245-b7c06fcb529e =\> success  
Importing Z:\oldTAC\00\01\0001131f-e8cf-451a-8956-03660215db39 =\> success  
Importing Z:\oldTAC\00\01\000119e0-f925-4d33-8b39-890d7530e7ca =\> success  
Importing Z:\oldTAC\00\01\00011b32-9660-4c36-812b-c1f5610a907b =\> ignored JSON file  
Importing Z:\oldTAC\00\01\00011c47-ae43-412e-9f76-d51bfa859bf5 =\> success  
Importing Z:\oldTAC\00\01\00013f58-e62f-4bc4-95bb-c19f2b706a65 =\> success  
Importing Z:\oldTAC\00\01\00015714-7fa5-43ed-8a6d-2590a2fc1e98 =\> ignored JSON file  
Importing Z:\oldTAC\00\01\00015afe-1f58-4f0d-8c9d-ac9ccdcb69e5 =\> ignored JSON file  
Importing Z:\oldTAC\00\01\00015d79-6acb-4d2f-a4fe-311000bcb45b =\> success  
Importing Z:\oldTAC\00\01\00015fef-3a3d-44bc-86f1-49cad8b3d80c =\> ignored JSON file  
Importing Z:\oldTAC\00\01\0001663d-6ef8-462b-97ae-b148c8afe98e =\> success

…

That is normal?

Thanks in advance,  
Ricardo Silva

A quarta-feira, 23 de fevereiro de 2022 à(s) 13:37:40 UTC, [alain.maz...@gmail.com](mailto:alain.maz...@gmail.com) escreveu:

---

<div class="post-metadata">

### Author: ![Alain\_Mazy](https://discourse.orthanc-server.org/letter_avatar_proxy/v4/letter/a/9de053/32.png) [@Alain\_Mazy](https://discourse.orthanc-server.org/u/Alain_Mazy)
#### Post date: [February 23, 2022, 3:02pm UTC](https://discourse.orthanc-server.org/t/migrate-sqlite-to-mysql/2810/8 "2022-02-23T15:02:21Z")

</div>

Great ! Yes, json files are ignored , this is normal. You won’t loose anything.
