# Using \`pystardog\` \`new\_stored\_query\` appears database agnostic

**URL:** https://community.stardog.com/t/using-pystardog-new-stored-query-appears-database-agnostic/4552
**Category:** Bug
**Created:** [August 16, 2023, 7:31pm UTC](https://community.stardog.com/t/using-pystardog-new-stored-query-appears-database-agnostic/4552 "2023-08-16T19:31:53Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![hall00ween](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/hall00ween/32/1752_2.png) [@hall00ween](https://community.stardog.com/u/hall00ween)
#### Post date: [August 16, 2023, 7:31pm UTC](https://community.stardog.com/t/using-pystardog-new-stored-query-appears-database-agnostic/4552/1 "2023-08-16T19:31:53Z")

</div>

Using `pystardog` I am uploading stored queries. Here is the code I use `pystardog` code:

```auto
        # Pull query data from file
        with open(query_file_path, 'r') as f:
            query_options = json.load(f)

        # Extract the needed information
        query_name = query_options.pop("name")
        query_text = query_options.pop("query")

        # Add build_database to options
        query_options["database"] = build_database
        
        # Handle 'None' values
        for key, value in query_options.items():
            if value == None:
                query_options[key] = 'None'

        # Push to Stardog cloud
        try:
            with stardog.admin.Admin(**conn_details) as admin:
                admin.new_stored_query(name=query_name, query=query_text, options=query_options)
        except Exception as err:
            print(f'Query likely exists. Error: {err}')

```

An example of the data stored in `query_file_path` is

```auto
{"name": "is-child-event-Query", "description": null, "creator": "hall0ween", "query": query_text_hidden, "shared": true, "reasoning": true}

```

Let's assume I have blank `dev` and `test` databases and the `build_database` variable is originally set to `dev`. The code functions as intended and uploads the queries without issues. If I then re-run the code changing `build_database` to test, I receive the feedback:

`Error: [422] QE0QE2: Stored query already exists: is-child-event-Query`

Is it possible to load queries of the same name to different databases? Thanks!
