Best Practices for Importing and Exporting Data
At this point, we have seen several different methods for reading and writing data between our computer and our database. Each method has its own use case and purpose. Generally, there are going to be two key factors that should guide your decision-making process:
- You should try to access the database with the same tool that you will use to analyze the data. As you add more steps to get your data from the database to your analytics tool, you increase the ways in which new errors can arise. When you can't access the database using the same tool that you will use to process the data, you should use
psql
to read and write CSV files to your database. - When writing data, you can save time by using the
COPY
or\copy
commands.
Going Password-Less
In addition to everything mentioned so far, it is also a good idea to set up a .pgpass
file. A .pgpass
file specifies the parameters that you use to connect to your database...