In one of my project, I'm using mongoengine 0.9 and pymongo 2.8 for the database and python django as a framework. I came through the view concept in mongodb and created a view in the database for a model named User. But I don't know how to access the view from mongodb using pymongo. Anyone have any suggestion, please help?
The error message I'm getting while trying to iterate over the cursor is:
database error: Namespace db.collection is a view. OP_GET_MORE operations are not supported on views. Only clients which support the getMore command can be used to query views.
MongoDB have feature called op codes in your case that is OP_GET_MORE to communicate with the db. Overtime some of these have been replaced and in your case client is not supporting getMore command. Please check your version.
Related
i have some trouble about influxdb+django configurations.
Firstly let me summarize my situation. I have an influxdb which is already collecting data from endnode(sensors). Data is transfering by LoraWan technology. I can read that datas from terminal by writing flux queries so database is working without any problem.
Now my second phase of this project is visualizing that datas on an web page. I am using django framework for that i completed the frontend parts nearly. I looked on internet for the configurations for influxdb on django but i couldnt handle it. In django documentation page they are listed some databases like below:
Django officially supports the following databases:
PostgreSQL
MariaDB
MySQL
Oracle
SQLite
How will i use/configure and get data from my influxdb ? Is it possible ? What are the alternative solutions.
Sure, Django doesn't support InfluxDB for its usual models (authentication and what-have-you, and of course your own apps), but you can simply use the InfluxDB Python client library to make a query in a view and e.g. return JSON data.
Adapting from the readme, you might have a view like
from influxdb_client import InfluxDBClient
client = InfluxDBClient(url="http://localhost:8086", token="my-token", org="my-org")
def get_data(request):
bucket = "my-bucket"
query_api = client.query_api()
result = query_api.query_csv('from(bucket:"my-bucket") |> range(start: -10m)')
return JSONResponse(result)
I am working on a project that requires connecting to an existing remote Oracle database. the problem is that the client has not given full access to the database. instead i'm only given accesss to some views(Relational Database View) of the database. the table names are not provided.
I'm able to perfrom raw sql queries to the legacydb in my django view.
But it would be very much more easier if i could generate the models for these views and use django ORM. is there any way to accomplish this? What I'm expecting is to use some commands like inspectdb to generate the models from the view provided by the oracle legacy database.
I am currently trying a few ways of connecting a postgre sql database that I already have defined using a django model with a front end angular form that I created within the same project. (This a a django project using a little bit angular js)
So basically I have a form which accepts data from a user, and the data needs to be stored in one of the tables of the postgre sql database that I already created.
I was following this but there are many points that are unclear to me. Is there a better way to solve this?
I am using REST api to get data from a mongodb on a server. Currently I can display the data from mongodb on to a browser using django rest framework, but this data is shown in JSON format.
I want to display this data it in a table.
I am still not clear on how to use this data in a template rather than just return a response that throws data onto a browser.Do I use a serializer for this ?
A google search revealed these 2 results:
Displaying a Table in Django from Database
http://django-tables2.readthedocs.org/en/latest/#tutorial
Both the code assume that the model is defined within the Django, but I am using the REST to get data.
I am using class based views and mixins as shown below for processing http requests on
class RestDjango(View, RequestMixin, ResponseMixin):
.........
.........
p.s:
I am using 0.3.3 version of Django REST Framework.
I am new to REST so please feel free to point me to any tutorials/articles to help me.
Do I use a serializer for this ?
No. You use renderer for this.
http://www.django-rest-framework.org/api-guide/renderers/#templatehtmlrenderer
I think the example code in the link is clear enough. Simply pass the query result as context and create your table inside template.
I'm having trouble getting my Django project to work with a CouchDB database.
I'm running Python 2.6.6, Django 1.3, and Lion on a Mac
I've got Django, CouchDB, and CouchDBKit installed. I can import all of them from the python interpreter without a problem. If I go to my CouchDB database URL, I can see the db.
The problem is, when I try to go to my django project URL, I get the following error:
You haven't set the database ENGINE setting yet.
I have the following lines in my settings.py file:
COUCHDB_DATABASES = (
('my_project.my_db', 'http://127.0.0.1:5984/my_db'),
)
The only possible solution I've found so far, is to set a throwaway database in the normal database engine settings. But, this just throws another error, because Django starts looking for database tables in the throw away DB.
Edit with new info:
I'm accessing my DB via an SSH tunnel
I'm able to create and access a CouchDB from the python interpeter.
I've run a test from the python interpreter, to access the app DB (again, via the tunnel), and the returned data accurately.
It's just when I try to access the actual site from a browser URL, I get the engine not defined error.
Django seems to be trying to use a normal DB (which isn't setup), instead of the CouchDB.
Any ideas?