Why I cannot create a database for graphite-web? - python

I am trying to install graphite-web on my computer by following the instructions on
https://gist.github.com/surjikal/2777886. When I try to populate the database with manage.py syncdb it does not find a proper database throwing the following error:
> sudo python manage.py syncdb
OperationalError: FATAL: database "/opt/graphite/storage/graphite.db" does not exist
Here you can find my database configuration from local_settings.py:
DATABASES = {
'default': {
'NAME': '/opt/graphite/storage/graphite.db',
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'USER': 'graphite',
'PASSWORD': '<password>',
'HOST': 'localhost',
'PORT': '5678'
}
}
Postgres is running properly:
sudo service --status-all | grep postgres
...
[ + ] postgresql
Why manage.py syncdb cannot create / find the graphite.db file?

If you are using postgresql then database path will not be required. You just need database name. like
DATABASES = {
'default': {
'NAME': 'graphite',
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'USER': 'graphite',
'PASSWORD': '<password>',
'HOST': 'localhost',
'PORT': '5678'
}
}

Related

django.db.utils.ProgrammingError: (1146, "Table 'Project.django_apscheduler_djangojob' doesn't exist")

I am learning django-apscheduler on the window system, And used python manage.py showmigrations command in terminal
but the result is 'django.db.utils.ProgrammingError: (1146, "Table 'Project.django_apscheduler_djangojob' doesn't exist")'
My DB setting
DATABASES = {
'default': {
# 'ENGINE': 'django.db.backends.sqlite3',
# 'NAME': BASE_DIR / 'db.sqlite3',
'ENGINE': 'django.db.backends.mysql',
'NAME': 'Product', # 数据库名称,
'HOST': '127.0.0.1', # 主机地址
'USER': 'root', # 数据库用户
'PASSWORD': 'password', # 密码
'PORT': 3306 # mysql的端口默认3306
}
}
Please help me, Thank you a lot
Run python manage.py migrate and restart server

django.db.utils.OperationalError: FATAL: database "clinilead_e " does not exist

After changing the db from sqlite to postgresql(python manage.py makemigrations)running, I am getting this error.How could i overcome this?
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'clinilead_e ',
'USER': 'postgres',
'PASSWORD': 'password',
'HOST': '127.0.0.1',
'PORT': '5432',
}
}
In postgres, unlike sqlite you have to create the database.
$ createdb clinilead_e

getting ConnectionDoesNotExist error when attempting to migrate mysql database in django

here's my code in django settings.py for the database:
DATABASES= {
'defualt': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'cameronkc',
'USER': 'root',
'PASSWORD': '123456',
'HOST': 'localhost',
'PORT': ''
}
}
here's the error im recieving when executing >python manage.py migrate in command prompt
django.db.utils.ConnectionDoesNotExist: The connection default doesn't exist
You misspelled default in your DATABASES dict. Change 'defualt' to 'default'.

postgresql django not sending password

I am getting the error OperationalError: fe_sendauth: no password supplied on my production server but I cannot see why...
settings.py
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'dbname',
'USER': 'dbuser',
'PASSWORD': PROD_DB_PASSWORD,
'HOST': 'localhost',
'PORT': '5432',
}
}
pg_hba.conf:
host dbname dbuser localhost md5
If I do psql -d dbname -U dbuser -h localhost and then enter the password at the prompt I can see that it works so IDK why django is not sending the password and IDK where to look from here.
I suspect you're not passing the password correctly. Here's how you debug. After the DATABASES line in settings.py, can you try printing out the dict.
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'dbname',
'USER': 'dbuser',
'PASSWORD': PROD_DB_PASSWORD,
'HOST': 'localhost',
'PORT': '5432',
}
}
print DATABASES
Then manage.py runserver as you would.
See if the password is properly passed. Apologies my rep's not enough to comment yet.
For future readers also check the spelling and later cases. All database keys must be in UPPER CASE e.g ENGINE, NAME, USER, PASSWORD, HOST and PORT.
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': os.getenv("DB_NAME", "db_name"),
"USER": os.getenv("DB_USERNAME", "db_user"),
"PASSWORD": os.getenv("DB_PASSWORD", "db#password"),
"HOST": os.getenv("DB_HOST", "localhost"),
"PORT": os.getenv("DB_PORT", "5432")
}
}

Django sql connection failed

I have created new project in django and write mysql connection in it's settings file like :
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'optdb',
'User': 'root',
'Password':'975',
'Host':'127.0.0.1',
'Port':'8080',
}
}
Now i write command : python manage.py syncdb and that generates following error:
How to solve this error mentioned above?
Note: I have currently one user in my MYSQL WAMP SERVER that is root with host 127.0.0.1.
All of those keys should be in capitals.
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'optdb',
'USER': 'root',
'PASSWORD':'975',
'HOST':'127.0.0.1',
'PORT':'8080',
}
}
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'optdb',
'USER': 'root',
'PASSWORD':'975',
'HOST':'127.0.0.1',
'PORT':'8080',
}
}
It's case sensitive...
Also, are you sure your mysql server is at port 8080? That's unusual. If unsure, just leave out that line and default mysql port will be used. See How can I connect to MySQL on a WAMP server?

Categories

Resources