# DatabaseError SQLite3 in my app

**URL:** <https://discuss.streamlit.io/t/databaseerror-sqlite3-in-my-app/17326>\
**Category:** Using Streamlit\
**Created:** [September 20, 2021, 5:15pm UTC](https://discuss.streamlit.io/t/databaseerror-sqlite3-in-my-app/17326 "2021-09-20T17:15:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Joaquin](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/joaquin/32/4233_2.png) [@Joaquin](https://discuss.streamlit.io/u/Joaquin)\
**Post date:** [September 20, 2021, 5:15pm UTC](https://discuss.streamlit.io/t/databaseerror-sqlite3-in-my-app/17326/1 "2021-09-20T17:15:53Z")

</div>

Hi, I have a problem with sqlite3 and streamlit.  
I have a data base called guia\_telefonica.db, which has records of diferent provinces.

I want to get and display a dataframe using the province name as a filter.

My code:

```auto
import pandas as pd
import sqlite3 as sql

db_guia = r"mypath\guia_telefonica.db"

seleccion_provincia = st.selectbox('Seleccionar Provincia',
        ('BUENOS AIRES','CIUDAD DE BUENOS AIRES', 'CATAMARCA', 'CHACO', 'CHUBUT',
            'CORDOBA', 'CORRIENTES', 'ENTRE RIOS',
        'FORMOSA', 'JUJUY', 'LA PAMPA', 'LA RIOJA', 'MENDOZA', 'MISIONES',
        'NEUQUEN', 'RIO NEGRO', 'SALTA', 'SAN JUAN', 'SAN LUIS',
        'SANTA CRUZ', 'SANTA FE', 'SANTIAGO DEL ESTERO',
        'TIERRA DEL FUEGO', 'TUCUMAN'))

def prov_db(provincia):
    conn = sql.connect(db_guia)
    df_provincia = pd.read_sql_query(f"SELECT * FROM [{provincia}]", conn)
    return df_provincia

st.write(prov_db(seleccion_provincia))

```

I have the next error:  
DatabaseError: Execution failed on sql ‘SELECT \* FROM [BUENOS AIRES]’: no such table: BUENOS AIRES

I can run this code in jupyter lab, using ANACONDA… but when I wanted to run it in my streamlit application I got the DatabasError

thanks in advance for any advice!

---

<div class="post-metadata">

**Author:** ![randyzwitch](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/randyzwitch/32/58772_2.png) [@randyzwitch](https://discuss.streamlit.io/u/randyzwitch)\
**Post date:** [September 20, 2021, 6:59pm UTC](https://discuss.streamlit.io/t/databaseerror-sqlite3-in-my-app/17326/2 "2021-09-20T18:59:57Z")

</div>

Hi @Joaquin, welcome to the Streamlit community!

Usually errors like this indicate that you have a bad reference to a file, usually due to starting Streamlit from a different folder than where you’re starting JupyterLab. Have you tried to put the exact file location into `db_guia`?

You might also want to move that variable inside the `prov_db` function, unless you expect to make that value selectable in the future. Otherwise, you’re referring to a global Python variable from inside of a function, which can sometimes have weird results.

Best,  
Randy
