2016-05-17 17 views
1

私はpostgresqlデータベースをpgAdmin IIIから削除しました(データベース/ mydatabaseを右クリックして削除/削除)。Operationalerror:データベースが存在しません

今私は新しいデータベースを作成する必要がある最初の移行を行いますが、代わりにデータベースが存在しないというエラーが発生します。

これまではsqlite3を使用していましたが、この手順が有効でした。 私は何をすべきですか?全traceback

(myvenv) c:\Python34\Scripts\possedimenti\sitopossedimenti>manage.py migrate 
Traceback (most recent call last): 
    File "c:\Python34\Scripts\possedimenti\myvenv\lib\site-packages\django\db\back 
ends\base\base.py", line 199, in ensure_connection 
    self.connect() 
    File "c:\Python34\Scripts\possedimenti\myvenv\lib\site-packages\django\db\back 
ends\base\base.py", line 171, in connect 
    self.connection = self.get_new_connection(conn_params) 
    File "c:\Python34\Scripts\possedimenti\myvenv\lib\site-packages\django\db\back 
ends\postgresql\base.py", line 175, in get_new_connection 
    connection = Database.connect(**conn_params) 
    File "c:\Python34\Scripts\possedimenti\myvenv\lib\site-packages\psycopg2\__ini 
t__.py", line 164, in connect 
    conn = _connect(dsn, connection_factory=connection_factory, async=async) 
psycopg2.OperationalError: FATALE: il database "possedimenti_database" non esis 
te 


The above exception was the direct cause of the following exception: 

Traceback (most recent call last): 
    File "C:\Python34\Scripts\possedimenti\sitopossedimenti\manage.py", line 10, i 
n <module> 
    execute_from_command_line(sys.argv) 
    File "c:\Python34\Scripts\possedimenti\myvenv\lib\site-packages\django\core\ma 
nagement\__init__.py", line 353, in execute_from_command_line 
    utility.execute() 
    File "c:\Python34\Scripts\possedimenti\myvenv\lib\site-packages\django\core\ma 
nagement\__init__.py", line 345, in execute 
    self.fetch_command(subcommand).run_from_argv(self.argv) 
    File "c:\Python34\Scripts\possedimenti\myvenv\lib\site-packages\django\core\ma 
nagement\base.py", line 348, in run_from_argv 
    self.execute(*args, **cmd_options) 
    File "c:\Python34\Scripts\possedimenti\myvenv\lib\site-packages\django\core\ma 
nagement\base.py", line 399, in execute 
    output = self.handle(*args, **options) 
    File "c:\Python34\Scripts\possedimenti\myvenv\lib\site-packages\django\core\ma 
nagement\commands\migrate.py", line 89, in handle 
    executor = MigrationExecutor(connection, self.migration_progress_callback) 
    File "c:\Python34\Scripts\possedimenti\myvenv\lib\site-packages\django\db\migr 
ations\executor.py", line 20, in __init__ 
    self.loader = MigrationLoader(self.connection) 
    File "c:\Python34\Scripts\possedimenti\myvenv\lib\site-packages\django\db\migr 
ations\loader.py", line 49, in __init__ 
    self.build_graph() 
    File "c:\Python34\Scripts\possedimenti\myvenv\lib\site-packages\django\db\migr 
ations\loader.py", line 176, in build_graph 
    self.applied_migrations = recorder.applied_migrations() 
    File "c:\Python34\Scripts\possedimenti\myvenv\lib\site-packages\django\db\migr 
ations\recorder.py", line 65, in applied_migrations 
    self.ensure_schema() 
    File "c:\Python34\Scripts\possedimenti\myvenv\lib\site-packages\django\db\migr 
ations\recorder.py", line 52, in ensure_schema 
    if self.Migration._meta.db_table in self.connection.introspection.table_name 
s(self.connection.cursor()): 
    File "c:\Python34\Scripts\possedimenti\myvenv\lib\site-packages\django\db\back 
ends\base\base.py", line 231, in cursor 
    cursor = self.make_debug_cursor(self._cursor()) 
    File "c:\Python34\Scripts\possedimenti\myvenv\lib\site-packages\django\db\back 
ends\base\base.py", line 204, in _cursor 
    self.ensure_connection() 
    File "c:\Python34\Scripts\possedimenti\myvenv\lib\site-packages\django\db\back 
ends\base\base.py", line 199, in ensure_connection 
    self.connect() 
    File "c:\Python34\Scripts\possedimenti\myvenv\lib\site-packages\django\db\util 
s.py", line 95, in __exit__ 
    six.reraise(dj_exc_type, dj_exc_value, traceback) 
    File "c:\Python34\Scripts\possedimenti\myvenv\lib\site-packages\django\utils\s 
ix.py", line 685, in reraise 
    raise value.with_traceback(tb) 
    File "c:\Python34\Scripts\possedimenti\myvenv\lib\site-packages\django\db\back 
ends\base\base.py", line 199, in ensure_connection 
    self.connect() 
    File "c:\Python34\Scripts\possedimenti\myvenv\lib\site-packages\django\db\back 
ends\base\base.py", line 171, in connect 
    self.connection = self.get_new_connection(conn_params) 
    File "c:\Python34\Scripts\possedimenti\myvenv\lib\site-packages\django\db\back 
ends\postgresql\base.py", line 175, in get_new_connection 
    connection = Database.connect(**conn_params) 
    File "c:\Python34\Scripts\possedimenti\myvenv\lib\site-packages\psycopg2\__ini 
t__.py", line 164, in connect 
    conn = _connect(dsn, connection_factory=connection_factory, async=async) 
django.db.utils.OperationalError: FATALE: il database "possedimenti_database" n 
on esiste 
+1

HMのDBを作成するために、 '手動possedimenti_database'データベースを作成してみてください。それから 'manage.py migrate'を呼び出してください。私はそれが願っています。 – Lucas03

答えて

1

まず移行は、データベースを作成しませんが、それはそれでテーブルを作成するために、既存のデータベースを必要とします。お使いの端末からPostgresデータベースの実行を作成するには

createdb -U postgres possedimenti_database 

あなたのデータベースユーザーに上記のコマンドではpostgresを交換する必要があります。

+1

私はsqlite3ではなくpostgresqlを使用しています – fabio

+1

端末からdbを作成するコマンドで私の答えを更新しました。 – ozren1983

1

DBのsettings.pyで詳細を確認してください。これらの正確な詳細(ポート番号、ユーザ、ホスト、パスワードなど)を使用してPostgreSQLデータベースを再作成します。ここでは、この既存のソリューションを試してみてくださいここにリンクされています

PostgreSQL - create a new DB through pgAdmin UI pgAdminで行う

関連する問題