- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试运行 sqlacodegen 从现有 PostgreSQL 数据库创建 SQLAlchemy 模型。
它不会运行。当我输入 sqlacodegen --help
时,我得到:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: bad operand type for unary -: '_Helper'
基本说明是here .
如何让 sqlacodegen 运行?
最佳答案
这是因为你是在 Python shell 中执行此操作的:
>>> import sqlacodegen
>>> sqlacodegen --help
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: bad operand type for unary -: '_Helper'
您应该在 Unix 命令 shell/Windows 命令提示符中执行 sqlacodegen --help
:
% sqlacodegen --help
usage: sqlacodegen [-h] [--version] [--schema SCHEMA] [--tables TABLES]
[--noviews] [--noindexes] [--noconstraints] [--nojoined]
[--noinflect] [--outfile OUTFILE]
[url]
Generates SQLAlchemy model code from an existing database.
positional arguments:
url SQLAlchemy url to the database
optional arguments:
-h, --help show this help message and exit
--version print the version number and exit
--schema SCHEMA load tables from an alternate schema
--tables TABLES tables to process (comma-separated, default: all)
--noviews ignore views
--noindexes ignore indexes
--noconstraints ignore constraints
--nojoined don't autodetect joined table inheritance
--noinflect don't try to convert tables names to singular form
--outfile OUTFILE file to write output to (default: stdout)
实际命令的示例如下:
% sqlacodegen --outfile models.py \
postgresql://gollyjer:swordfish@localhost:5432/mydatabase
其中 gollyjer:swordfish
是您的凭据,格式为 user:password
。
关于python - 如何运行sqlacodegen?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28788186/
我在服务器上运行 PostgreSQL 数据库,并尝试使用 SQLAlchemy 连接到它。我发现 sqlacodegen是自动生成元数据对象及其表的好工具。但是当我尝试运行 sqlacodgen p
我正尝试在我的数据库上使用sqlacodegen。 sqlacodegen mysql://root:mypassword@localhost/database_name 但是,我不断收到此错误: s
执行这条命令: sqlacodegen --outfile db.py db.py 包含生成的表: t_table1 = Table(...) 还有类: Table2(Base): __ta
我有一个有用的 PostgreSQL View ,由 JOIN 查询生成: \d very_useful_view; View "public.very_useful_view" Column
当我使用 sqlacodegen 创建 models.py 时,我无法使用 User.query,收到警告“[AttributeError: type object 'User' has no att
我是 Python 和 Flask 生态系统的初学者,正在尝试为研究项目创建一个小型的概念验证 Web 应用程序。我正在使用 Debian Linux 7.9、PostgreSQL 9.5、SQLAl
我在 postgresql 中自动生成表,模型是使用列表中的名称使用 sqlacodegen 自动生成的。 一些名称是非 ascii 字符。对于名称 💞aussieBabe💞,它创建了一个表 💞
我是一名优秀的程序员,十分优秀!