From an existing .SQL file
If you want to upload data from an existing
.sql file, you can do this on the command line.
Be aware! The commands in a
.sqlfile can delete & change any data in an existing repo!
YOU CAN DELETE ALL THE DATA IN YOUR REPO WITH THE COMMANDS IN A .SQL FILE.
Install the Postgres tools
You'll need to be comfortable with using the command line. Our focus here is on OS X and Linux, but the same commands are available for Windows (but require slightly different commands).
First, install the Postgres command line tools.
On OS X or Windows, the easiest to use the Postgres 14.1 installer from EDB: https://www.enterprisedb.com/downloads/postgres-postgresql-downloads
Install Postgres, and make sure you include the command line tools.
On Linux, install postgres via your package manager; on Ubuntu-based systems you can do this with
sudo apt-get install postgresql-client-12 which will install the client you need (the version 12 client is fine; the version 13 or 14 client will work as well).
psql To Upload Data To bit.io
psqlTo Upload Data To bit.io
Start a command prompt.
Change to the directory where your
.sql file is.
Go to bit.io and copy you password - click on the green
connect button, and you'll see your password. Click on your password and it'll be copied to your clipboard.
Then, you are going to run the
psql -U <your username> -h db.bit.io -d <your database name> -f <your sql file name>
<your username> with your bit.io username, and replace
<your sql file name> with the name of your sql file. Replace
<your database name> with your fully database name, e.g.
Here's an example for the user
adam with the file
Adams-Mac-mini:~ adam$ psql -U adam -h db.bit.io -d bitdotio -f test.sql Password for user adam: INSERT 0 1 Adams-Mac-mini:~ adam$ cat test.sql INSERT INTO "adam/test_sql_file_input"."test" (test_column) VALUES ('Hello, world!')
And look, it's in the repo:
psql command will run for as many commands are in the file.
Updated 9 months ago