question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to choose between development or production environment in a Doctype class

See original GitHub issue

Hi,

I have this Doctype class to work with persistence in my project.

#developtment is a boolean variable.

from config import cluster,cluster_test, development
from elasticsearch import Elasticsearch
from elasticsearch.helpers import scan

if development:
    # We change to cluster from development
    es = Elasticsearch(cluster_test)
    connections.create_connection(hosts = cluster_test)

else:
    es = Elasticsearch(cluster)
    connections.create_connection(hosts = cluster)


class MyExampleClass(DocType):

    MyString = String(index='not_analyzed')
    AnotherParameter = String(index='not_analyzed')
    timestamp = Date()
    updated_at = Date()


There is another way to declare this class to connect this class to production or development environment without modify the development variable in the configuration file and passing development as a paremeter to this class.

Thanks in advance.

Best regards

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
juandasgandarascommented, Jul 26, 2016

ok, thanks for your help !!

0reactions
honzakralcommented, Jul 26, 2016

Happy to help. Note that you really shouldn’t need access to the Elasticsearch instance for the most common operations - all the dsl methods support using kwarg which you can just pass the alias (dev in this case) as a string.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Difference Between Development, Stage, And Production
The production environment is where users access the final code after all of the updates and testing. Of all the environments, this one...
Read more >
Understanding environments - Janel Brandon - Medium
Each developer on a team has their own development environment, and each developer is responsible for making sure that their development ...
Read more >
Using Multiple Environments to Improve Your Development ...
Production : Once the code has been thoroughly tested, it is then pushed to production where it is made available to end-users. The...
Read more >
Environments | Codecademy
In this article, you'll learn about the different environments that a project can be in as it goes through the process of development...
Read more >
Optimized Development Environment: Pydantic Tutorial, Part 2
Learn how to develop a Django application coupled with pydantic where the development environment matches production.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found