Python 关系“;表名“;为postgresql表加载而运行heroku时不存在错误 我无法通过批处理运行将数据加载到postgres表中*
例: 我对下面的错误感到失望 运行python ProddbUpload.pyPython 关系“;表名“;为postgresql表加载而运行heroku时不存在错误 我无法通过批处理运行将数据加载到postgres表中*,python,postgresql,django-models,relation,heroku-postgres,Python,Postgresql,Django Models,Relation,Heroku Postgres,例: 我对下面的错误感到失望 运行python ProddbUpload.py heroku run python ProddbUpload.py 使用pg:psql在heroku环境中的my Postgres数据库中存在已验证的表名Spellbeeword_tb 我的代码上传数据到上述表格 on ⬢ spellbeeword... up, run.9508 (Free) relation "spellbeeword_tb" does not exist 在pg:p
heroku run python ProddbUpload.py
使用pg:psql在heroku环境中的my Postgres数据库中存在已验证的表名Spellbeeword_tb
我的代码上传数据到上述表格
on ⬢ spellbeeword... up, run.9508 (Free)
relation "spellbeeword_tb" does not exist
在pg:psql查询中,它显示
我的表的数据库连接为-->连接到postgresql-flat-40316
但在heroku环境变量中,它显示为==拼写单词配置变量 数据库URL:postgres://mlsudzmqspljyc:c2e68f055e685aa45dde87@ec2-18-206-20-102.compute-1.amazonaws.com: 默认情况下,上面的配置已完成 我不知道如何连接postgresql-flat-40316/Spellbeeword\u tb 当我检查以下代码时,没有打印任何内容 cur.execute('SELECT version()')) 显示PostgreSQL数据库服务器版本 db_version=cur.fetchone() 打印(db_版)
我认为,在heroku run中,没有识别要连接的正确数据库
我遵循了heroku postgresl django部署文档,其中数据库URL由dj数据库URL安装配置
我通过heroku run python运行了上面的dbupload代码 在这次运行之前,requirements和settings.py被分别推送到heroku #设置数据库url DATABASES={'default':dj_database_url.config()} 查看我当前的pg状态
Pls help me to import my data into table created by django model in heroku.
表格行:('d7uobuibp87kvk','public','Spellbeeword_tb','BASE table',None,None,None,None,'YES','NO',None)
在数据库中,我的目标表存在,但它显示
=== DATABASE_URL
Plan: Hobby-dev
Status: Available
Connections: 0/20
PG Version: 13.2
Created: 2021-04-06 10:54 UTC
Data Size: 9.0 MB
Tables: 13
Rows: 68/10000 (In compliance)
Fork/Follow: Unsupported
Rollback: Unsupported
Continuous Protection: Off
Add-on: postgresql-flat-40316
任何人都可以建议如何在代码中指定表名以识别现在我发现它对表名中的混合大小写是区分大小写的。因此,我在“双引号”中给出了表名,这样它就可以识别表了
relation "spellbeeword_tb" does not exist
LINE 1: SELECT * FROM Spellbeeword_tb;
^
并且没有为上述sql语句抛出错误并获取表。。。。
但关系不存在,因为下面的代码仍然存在
`cur.execute('SELECT * FROM "Spellbeeword_tb";')`
关系“spellbeeword_tb”不存在最终确定的Postgres数据库区分大小写。根据Camel case中定义的表,它无法识别表名关系(尽管表以引号形式给出(均为“/”) 因此我将表名改为小写。现在它可以识别表了
relation "spellbeeword_tb" does not exist
LINE 1: SELECT * FROM Spellbeeword_tb;
^
`cur.execute('SELECT * FROM "Spellbeeword_tb";')`
cur.copy_from(f,"Spellbeeword_tb",sep=',')