问题:

尝试连接到mysql的数据库时我面临的问题。 我还提供了我使用过的数据库设置。

 Traceback (most recent call last):
 File "manage.py", line 10, in <module>
 execute_from_command_line(sys.argv)
 File "/home/ar/Desktop/test/testprac/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 453, in execute_from_command_line
utility.execute()
File "/home/ar/Desktop/test/testprac/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/ar/Desktop/test/testprac/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 272, in fetch_command
klass = load_command_class(app_name, subcommand)
File "/home/ar/Desktop/test/testprac/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 77, in load_command_class
module = import_module('%s.management.commands.%s' % (app_name, name))
File "/home/arundhati/Desktop/test/testprac/local/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/home/ar/Desktop/test/testprac/local/lib/python2.7/site-packages/django/core/management/commands/syncdb.py", line 8, in <module>
from django.core.management.sql import custom_sql_for_model, emit_post_sync_signal
File "/home/ar/Desktop/test/testprac/local/lib/python2.7/site-packages/django/core/management/sql.py", line 9, in <module>
from django.db import models
File "/home/ar/Desktop/test/testprac/local/lib/python2.7/site-packages/django/db/__init__.py", line 40, in <module>
backend = load_backend(connection.settings_dict['ENGINE'])
File "/home/ar/Desktop/test/testprac/local/lib/python2.7/site-packages/django/db/__init__.py", line 34, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "/home/ar/Desktop/test/testprac/local/lib/python2.7/site-packages/django/db/utils.py", line 93, in __getitem__
backend = load_backend(db['ENGINE'])
File "/home/ar/Desktop/test/testprac/local/lib/python2.7/site-packages/django/db/utils.py", line 27, in load_backend
return import_module('.base', backend_name)
File "/home/ar/Desktop/test/testprac/local/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/home/ar/Desktop/test/testprac/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 17, in <module>
raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb

数据库设置::

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': 'ar_test_db',                      # Or path to database file if using 
        # The following settings are not used with sqlite3:
        'USER': '',
        'PASSWORD': '',
        'HOST': '',                      # Empty for localhost through domain sockets or   '127.0.0.1' for localhost through TCP.
        'PORT': '',                      # Set to empty string for default.
    }
}

非常感谢您的帮助 !!

The problem Im facing while trying to connect to database for mysql.I have also given the database settings that i have used.Databse Settings::Thanks a lot for the help !!

问题:

遵循这个Django by example tutotrial: http ://lightbird.net/dbe/todo_list.html

教程说:

“这改变了我们的表格布局,我们必须要求Django重置并重新创建表格:

manage.py reset todo; manage.py syncdb manage.py reset todo; manage.py syncdb

但是,当我运行manage.py reset todo ,我收到错误:

$ python manage.py reset todo                                       
- Unknown command: 'reset'

这是因为我使用的是sqlite3而不是postgresql吗?

有人能告诉我重置数据库的命令是什么吗?

命令: python manage.py sqlclear todo返回错误:

$ python manage.py sqlclear todo    
CommandError: App with label todo could not be found.    
Are you sure your INSTALLED_APPS setting is correct?

所以我在settings.py中将’todo’添加到我的INSTALLED_APPS中,并再次运行python manage.py sqlclear todo ,导致此错误:

$ python manage.py sqlclear todo                                      
- NameError: name 'admin' is not defined

Following this Django by Example tutotrial here: http://lightbird.net/dbe/todo_list.htmlThe tutorial says:”This changes our table layout and we’ll have to ask Django to reset and recreate tables:manage.py reset todo; manage.py syncdb “though, when I run manage.py reset todo , I get the error:Is this because I am using sqlite3 and not postgresql?Can somebody tell me what the command is to reset the database?The command: python manage.py sqlclear todo returns the error:So I added ‘todo’ to my INSTALLED_APPS in settings.py, and ran python manage.py sqlclear todo again, resulting in this error:

问题:

我之前看到这个问题了,但仅限于rspec的。 我还没有创建测试,因为它对我来说太提前了,但是我很快就会! 😛

当我尝试使用我的应用程序注册/登录时出现此错误。 我不确定要在哪里修复它。 我使用devise创建我的用户,也使用omn​​iauth2使用google登录。

这是错误

ActiveRecord::StatementInvalid at /users/auth/google_oauth2/callback
PG::UndefinedTable: ERROR:  relation "users" does not exist
LINE 5:              WHERE a.attrelid = '"users"'::regclass
                                        ^
:             SELECT a.attname, format_type(a.atttypid, a.atttypmod),
                     pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
              FROM pg_attribute a LEFT JOIN pg_attrdef d
                ON a.attrelid = d.adrelid AND a.attnum = d.adnum
             WHERE a.attrelid = '"users"'::regclass
               AND a.attnum > 0 AND NOT a.attisdropped
             ORDER BY a.attnum

我试过rake db:migrate ,但是已经存在,在模式表用户中已经存在。 有人之前收到此错误吗?

数据库

#   gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
# On Windows:
#   gem install pg
#       Choose the win32 build.
#       Install PostgreSQL and put its /bin directory on your path.
#
# Configure Using Gemfile
# gem 'pg'
#
development:
  adapter: postgresql
  encoding: unicode
  database: tt_intraweb_development
  pool: 5
  username: my_username
  password:

  # Connect on a TCP socket. Omitted by default since the client uses a
  # domain socket that doesn't need configuration. Windows does not have
  # domain sockets, so uncomment these lines.
  #host: localhost
  #port: 5432

  # Schema search path. The server defaults to $user,public
  #schema_search_path: myapp,sharedapp,public

  # Minimum log levels, in increasing order:
  #   debug5, debug4, debug3, debug2, debug1,
  #   log, notice, warning, error, fatal, and panic
  # The server defaults to notice.
  #min_messages: warning

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
  adapter: postgresql
  encoding: unicode
  database: tt_intraweb_test
  pool: 5
  username: my_username
  password:

production:
  adapter: postgresql
  encoding: unicode
  database: tt_intraweb_production
  pool: 5
  username: my_username
  password:

I see this question up before, but only for rspec.I am not create test yet because its too advance for me but one day soon i will!:PI am getting this error when i try to sign up/ log in with my app.I’m not sure where to look to fix it.I use devise to create my user and also omniauth2 to sign in with google .this is the errorI tried rake db:migrate , but it already is created, in schema table users exist.has anyone get this error before?database.yml

问题:

$ ./mysqladmin -u root -p ‘已编辑
输入密码:

mysqladmin:连接到“ localhost”服务器失败错误:
‘拒绝用户’root’@’localhost’的访问(使用密码:是)’

我怎样才能解决这个问题?

$ ./mysqladmin -u root -predacted ‘Enter password:mysqladmin: connect to server at ‘localhost’ failed error:‘Access denied for user ‘root’@’localhost’ (using password: YES)’How can I fix this?