[英]Ruby on rails load local csv data to heroku
I am trying to import data to a postgres database in heroku. 我正在尝试将数据导入heroku中的postgres数据库。 I am able to upload the correct schema to heroku by using the command:
我可以使用以下命令将正确的架构上传到heroku:
heroku pg:psql -a [app name] < db/structure.sql
so now when I run heroku pg:psql and connect to my database I can run: 所以现在当我运行heroku pg:psql并连接到数据库时,我可以运行:
\dt
and it lists all of the tables that I want. 它列出了我想要的所有表。 However, only the schema is uploaded, not the actual data.
但是,仅上载架构,而不上载实际数据。 I have looked over a bunch of different ways to upload databases to heroku, but have been unable to get any to work.
我研究了多种将数据库上传到heroku的方法,但是一直无法正常工作。 I was wondering if there is an easy way to import local csv data to heroku.
我想知道是否有一种简单的方法将本地csv数据导入到heroku。 Locally, I can run:
在本地,我可以运行:
sqlite3 development.sqlite3
.mode csv
.import [table name] [filename]
And it imports the data that I want. 并导入我想要的数据。 Is there a similar way to do this for heroku databases?
是否有类似的方法用于heroku数据库? I know that heroku uses postgres and not sqlite3, but since I was able to load the schema easily, I thought there might be an easy way to upload data.
我知道heroku使用的是postgres而不是sqlite3,但是由于我能够轻松加载架构,因此我认为可能有一种上传数据的简便方法。 This is my first ruby on rails project I've ever attempted to publish, so any guidance would be appreciated!
这是我尝试发布的第一个ruby on rails项目,因此任何指导将不胜感激! Thanks!
谢谢!
Upload your csv to heroku and run 将您的csv上传到heroku并运行
COPY zip_codes FROM '/path/to/your_file.csv' DELIMITER ',' CSV;
in pg shell 在pg shell中
Look https://gist.github.com/jboesch/5605747 , Importing csv to heroku postgres how you can do it 看https://gist.github.com/jboesch/5605747 , 将csv导入heroku postgres如何实现
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.