<p>You can do it via the <a href="https://astroquery.readthedocs.io/en/latest/sdss/sdss.html" rel="noreferrer">astroquery SDSS module</a>; there is a function called <a href="https://astroquery.readthedocs.io/en/latest/api/astroquery.sdss.SDSSClass.html#astroquery.sdss.SDSSClass.query_sql" rel="noreferrer">query_sql</a>.</p>

CC BY-SA 4.0
2021-04-05T13:28:07.283Z
2021-04-05T13:28:07.283Z
Eric Jensen
<p>Is there a way to directly access any of the <a href="https://en.wikipedia.org/wiki/Sloan_Digital_Sky_Survey" rel="nofollow noreferrer">Sloan Digital Sky Survey</a> servers via SQL via Python?</p>
<p>Currently I have been able to run SQL queries from the website they provide (for example <a href="https://skyserver.sdss.org/dr12/en/tools/search/sql.aspx" rel="nofollow noreferrer">https://skyserver.sdss.org/dr12/en/tools/search/sql.aspx</a>), but it's not clear to me how I can access them directly from a Python interface.</p>
<p>Any suggestions what connection details I would need to use are highly appreciated.</p>

CC BY-SA 4.0
2021-04-04T02:46:09.423Z
I’d be surprised—that would imply giving out their password, potentially opening the door to malignant users. Granted, it wouldn’t be the main password, and it would have restricted privileges, but it would still be a potentially dangerous practice.
Pierre Paquette
<data-analysis><python><sky-survey><sloan-dss>
Accessing SDSS server SQL server via python
Nickpick
# Accessing SDSS server SQL server via python

(Asked by: username_0 on 2021-04-03)

Is there a way to directly access any of the [Sloan Digital Sky Survey](https://en.wikipedia.org/wiki/Sloan_Digital_Sky_Survey) servers via SQL via Python?

Currently I have been able to run SQL queries from the website they provide (for example <https://skyserver.sdss.org/dr12/en/tools/search/sql.aspx>), but it's not clear to me how I can access them directly from a Python interface.

Any suggestions what connection details I would need to use are highly appreciated.

**Tags:** data-analysis, python, sky-survey, sloan-dss
> **Comments:**
> **username_1**: I’d be surprised—that would imply giving out their password, potentially opening the door to malignant users. Granted, it wouldn’t be the main password, and it would have restricted privileges, but it would still be a potentially dangerous practice.  

---

## 1 answers

### Answer by username_2 on 2021-04-05. Score: 7

You can do it via the [astroquery SDSS module](https://astroquery.readthedocs.io/en/latest/sdss/sdss.html); there is a function called [query\_sql](https://astroquery.readthedocs.io/en/latest/api/astroquery.sdss.SDSSClass.html#astroquery.sdss.SDSSClass.query_sql).


---

