# Query a Maria DB

**URL:** https://discourse.orthanc-server.org/t/query-a-maria-db/1203
**Category:** Google Groups archive
**Created:** [November 18, 2018, 11:18am UTC](https://discourse.orthanc-server.org/t/query-a-maria-db/1203 "2018-11-18T11:18:51Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![Max](https://discourse.orthanc-server.org/user_avatar/discourse.orthanc-server.org/max/32/1577_2.png) [@Max](https://discourse.orthanc-server.org/u/Max)
#### Post date: [November 18, 2018, 11:18am UTC](https://discourse.orthanc-server.org/t/query-a-maria-db/1203/1 "2018-11-18T11:18:51Z")

</div>

Hello,

is it possible to make a query (SELECT) on MariaDB with an Orthanc DB to retrive :

AccessionNumber, Study Instance UID and the study ID (I mean the the one retrived with Curl command)

Thanks

Max

---

<div class="post-metadata">

### Author: ![Alain\_Mazy3](https://discourse.orthanc-server.org/letter_avatar_proxy/v4/letter/a/eb9ed0/32.png) [@Alain\_Mazy3](https://discourse.orthanc-server.org/u/Alain_Mazy3)
#### Post date: [November 19, 2018, 7:51am UTC](https://discourse.orthanc-server.org/t/query-a-maria-db/1203/2 "2018-11-19T07:51:42Z")

</div>

Well, you can query the DB directly if you wish but we always recommend to use the API instead: [http://book.orthanc-server.com/users/rest.html#performing-finds-within-orthanc](http://book.orthanc-server.com/users/rest.html#performing-finds-within-orthanc)

---

<div class="post-metadata">

### Author: ![Max](https://discourse.orthanc-server.org/user_avatar/discourse.orthanc-server.org/max/32/1577_2.png) [@Max](https://discourse.orthanc-server.org/u/Max)
#### Post date: [November 21, 2018, 9:38am UTC](https://discourse.orthanc-server.org/t/query-a-maria-db/1203/3 "2018-11-21T09:38:43Z")

</div>

Sorry what is the syntax error in this query ?

```auto
--request POST --url [http://localhost:8042/tools/find](http://localhost:8042/tools/find) --data '{"Level":"Instance","Query":{"AccessionNumber”:”86472”}}'

```

Biotron spa

---

<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: [November 21, 2018, 11:48am UTC](https://discourse.orthanc-server.org/t/query-a-maria-db/1203/4 "2018-11-21T11:48:46Z")

</div>

You use non-ASCII quotes (”) in this query. Try with:

$ curl --request POST --url [http://localhost:8042/tools/find](http://localhost:8042/tools/find) --data ‘{“Level”:“Instance”,“Query”:{“AccessionNumber”:“86472”}}’

---

<div class="post-metadata">

### Author: ![Max](https://discourse.orthanc-server.org/user_avatar/discourse.orthanc-server.org/max/32/1577_2.png) [@Max](https://discourse.orthanc-server.org/u/Max)
#### Post date: [November 21, 2018, 12:56pm UTC](https://discourse.orthanc-server.org/t/query-a-maria-db/1203/5 "2018-11-21T12:56:26Z")

</div>

This is what happens :

C:\curl-7.62.0-win64-mingw\bin\>curl --request POST --url [http://localhost:8042/t](http://localhost:8042/t)  
ools/find --data ‘{“Level”:“Instance”,“Query”:{“AccessionNumber”:“86472”}}’  
{  
“HttpError” : “Bad Request”,  
“HttpStatus” : 400,  
“Message” : “Bad request”,  
“Method” : “POST”,  
“OrthancError” : “Bad request”,  
“OrthancStatus” : 8,  
“Uri” : “/tools/find”  
}

Any ideas ?

Max

---

<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: [November 21, 2018, 1:00pm UTC](https://discourse.orthanc-server.org/t/query-a-maria-db/1203/6 "2018-11-21T13:00:32Z")

</div>

The escaping rules for quotes are different on Windows (that you use) and on Linux (that I use):  
[https://en.wikipedia.org/wiki/Escape\_character#Windows\_Command\_Prompt](https://en.wikipedia.org/wiki/Escape_character#Windows_Command_Prompt)

I let Windows users provide the good command line.

---

<div class="post-metadata">

### Author: ![Alain\_Mazy3](https://discourse.orthanc-server.org/letter_avatar_proxy/v4/letter/a/eb9ed0/32.png) [@Alain\_Mazy3](https://discourse.orthanc-server.org/u/Alain_Mazy3)
#### Post date: [November 21, 2018, 2:15pm UTC](https://discourse.orthanc-server.org/t/query-a-maria-db/1203/7 "2018-11-21T14:15:55Z")

</div>

curl --request POST --url [http://localhost:8042/tools/find](http://localhost:8042/tools/find) --data “{"Level":"Instance","Query":{"AccessionNumber":"86472"}}”

---

<div class="post-metadata">

### Author: ![Max](https://discourse.orthanc-server.org/user_avatar/discourse.orthanc-server.org/max/32/1577_2.png) [@Max](https://discourse.orthanc-server.org/u/Max)
#### Post date: [November 21, 2018, 2:28pm UTC](https://discourse.orthanc-server.org/t/query-a-maria-db/1203/8 "2018-11-21T14:28:02Z")

</div>

Thank u very much !

And if I have a system with user authentication, what is the correct syntax for user “test” and pw “test1” ?

I mean like :

[http://localhost:8042/osimis-viewer/app/index.html?user=test&password=test1&study=b610a703-ae8920e6-61753a51-9ba91ecc-1f72674a](http://localhost:8042/osimis-viewer/app/index.html?user=test&password=test1&study=b610a703-ae8920e6-61753a51-9ba91ecc-1f72674a)

(but this do not work…)

Max

---

<div class="post-metadata">

### Author: ![Alain\_Mazy3](https://discourse.orthanc-server.org/letter_avatar_proxy/v4/letter/a/eb9ed0/32.png) [@Alain\_Mazy3](https://discourse.orthanc-server.org/u/Alain_Mazy3)
#### Post date: [November 21, 2018, 3:23pm UTC](https://discourse.orthanc-server.org/t/query-a-maria-db/1203/9 "2018-11-21T15:23:56Z")

</div>

Please check the resources on the web about HTTP basic authentication. This is an Orthanc forum, not a general HTTP forum.  
[http://lmgtfy.com/?q=how+to+pass+basic+authentication+in+url](http://lmgtfy.com/?q=how+to+pass+basic+authentication+in+url)

---

<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: [November 24, 2018, 12:26pm UTC](https://discourse.orthanc-server.org/t/query-a-maria-db/1203/10 "2018-11-24T12:26:27Z")

</div>

Here would be the corresponding URL:  
[http://test:test1@localhost:8042/osimis-viewer/app/index.html?study=b610a703-ae8920e6-61753a51-9ba91ecc-1f72674a](http://test:test1@localhost:8042/osimis-viewer/app/index.html?study=b610a703-ae8920e6-61753a51-9ba91ecc-1f72674a)

If using curl, you can use the “-u” command-line option:

# curl -u test:test1 [http://localhost:8042/system](http://localhost:8042/system)

HTH,  
Sébastien-
