Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Postgresql 使用sqlalchemy连接到Postgres_Postgresql_Sqlalchemy - Fatal编程技术网

Postgresql 使用sqlalchemy连接到Postgres

Postgresql 使用sqlalchemy连接到Postgres,postgresql,sqlalchemy,Postgresql,Sqlalchemy,我使用的是一台Windows10机器,本地安装了Postgres,我试图使用Python访问它 我收到一个错误,根据下面的代码称为“mydatabase”的数据库不存在。实际消息是“psycopg2.OperationalError:致命:数据库“mydatabase”不存在。” 从sqlalchemy导入(元数据、表、列、整数、数字、字符串、, DateTime、ForeignKey、create_引擎) 引擎=创建引擎('postgresql://postgres:helpdeskNo1@l

我使用的是一台Windows10机器,本地安装了Postgres,我试图使用Python访问它

我收到一个错误,根据下面的代码称为“mydatabase”的数据库不存在。实际消息是“psycopg2.OperationalError:致命:数据库“mydatabase”不存在。”

从sqlalchemy导入(元数据、表、列、整数、数字、字符串、, DateTime、ForeignKey、create_引擎)


引擎=创建引擎('postgresql://postgres:helpdeskNo1@localhost:5432/mydatabase')

关于这个错误还有什么不清楚的地方?我对类似sqlalchemy的ORM的理解是,它允许用户在代码中定义类,然后将这些类转换为相关的数据库引擎。在本例中,我已经定义了类,因此我希望ORM向数据库引擎发出SQL语句,从而创建数据库。ORM通常能够为您创建表,但他们通常希望数据库存在。只需使用类似于创建数据库的工具,然后从那里开始。