I'm a Django developer getting to grips with Node/Express. I have been given an existing Node repo to work with. How do I set up the database?
In other words, what's the Node equivalent of editing localsettings.py with the database name and login details, and then running:
$ python manage.py syncdb
to set up the database schema for the app?
I know the app has a Mongo back-end, but that's all I know.
There isn't something as sophisticated as that. You will need to connect to it, every time you want to use it. Make sure you've set mongodb up, and if you have not, this is an excellent video on how to set it up.
Now that you've got it as a service, you can start using mongodb. First, install mongoose, like so:
npm install mongoose
Then you can connect to your mongodb server like so:
var mongoose = require("mongoose");
mongoose.connect("mongodb://localhost/<db_name_here>");
// Sample schema
var UserSchema = new mongoose.Schema({
email: String,
name: String,
age: Number
});
You can learn more about how to use mongoose here ->.
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 using the syncfusion ej2 Angular Scheduler App, I want to know that how can i add the appointment data that i provided in it to my local database.
What should be the correct approach to do it in django if i want to add the data to mongodb?
We have validated your reported query “How to add the appointment data from Angular Scheduler app to a local database?” at our end. A quick start project that available in the below link helps you to create the Syncfusion Angular Scheduler with Mongo DB. We are not aware of the Django. So, we suggest you refer to the below link for work with Angular Scheduler with Mongo DB.
Sample: https://github.com/SyncfusionExamples/ej2-angular-scheduler-mongodb
Kindly try the above sample and get back to us if you need any further assistance.
UG(Data binding with Angular Scheduler component): https://ej2.syncfusion.com/angular/documentation/schedule/data-binding/
I set up a simple django site using django-allauth.
I created some oauth providers in the database.
Everything is fine and working on my laptop now.
I would like to store the created database tables somehow.
Use case: I want to set up a new development environments on a different PC painlessly.
How to store the initial data of django_allauth, so that after checking out the app from git the command manage.py migrate is all I need to have the relevant database tables filled?
Django_allauth already save those data to the database, you will find them in a table *_SocialApp, here is the model code from django_auth source
I am looking for an example about how to display git log data about a commit.
I get the commit via shell script; then retrieve the info about this commit and make it pretty. Now I would like to add on a web app in Django, the capability to pass hash and project repo name, so I can display thee info in a nice way.
Altho I can't find tutorial that show how to build a web app for django, that display a page in this way. I just start with the tutorials today, so I don't know much. I also need to read from file, so I don't need a database nor the model, right?
IS this too complicate for a first Django app?
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?