Two handy examples of the psql \copy meta-command.

In this blog post, I will cover example uses of the psql \copy meta-command, for client-side work with the PostgreSQL database server. This command allows users who do not have Superuser privileges, to perform COPY type SQL commands.

(more…)

Utility psql command for saving query output to a file.

Ever needed or wanted to save particular query results for later? Perhaps you need to really study something for better understanding. Scrutinize a dataset with a hawk’s eye while having a coffee? Or just list out all of the tables in the database you are working in? The psql \o meta-command is your new best friend.

(more…)

TRUNCATE table example in PostgreSQL.

In a previous blog post, I selected records from the staging_assets table to insert into their respective table, depending on the type of asset. Let’s empty out this table, yet keep the structure in place for future uploads, using the TRUNCATE command.

(more…)

Wholesale inserts with Python, Psycopg2 and PostgreSQL.

Triple P threat to all data files!!! Hahahaha… Now that I have myself collected and together, in this blog post I will utilize Python, Psycopg2, and PostgreSQL for a bulk upload, importing data from a CSV file to a database table. (more…)

Data prepping with Sed for bulk uploads using the PostgreSQL COPY command.

This post will highlight usage of the PostgreSQL COPY command. Along the way, I will use Sed, a Unix command-line utility, to ‘massage’ sample data into a more uniformed structure. Once the data has been formatted to our requirement, we will then load it into a PostgreSQL table.

(more…)

Fabulous fabrication asset tracking using JOINS in PostgreSQL

This post will demonstrate mock asset tracking with PostgreSQL for a pipe fabrication setting. The typical data one would track and record in this setting are bends, weld id’s, and joints of pipe. We will see powerful queries from multiple tables, return informative and useful data with the JOIN command.

(more…)