Python and psycopg2 for CSV bulk upload in PostgreSQL – with examples…

In a previous post, I explored using both the COPY command and the CAST() function together in order to upload an entire CSV file’s data into a PostgreSQL database table. This post is a continuation, of sorts. However, I will use Python and the psycopg2 library, in a simple script, to handle these uploads instead of SQL. While I am still a novice with operations such as these, I feel that writing about it is a fantastic way to learn and obtain valuable feedback…

[Head this way for great PostgresSQL blogging >>>]
Advertisements

COPY and CAST() – Bulk uploads in PostgreSQL

Loading data into database tables is pretty much a necessity. Without data, what do we have? Not much at all. The CSV format is super common, used far and wide. I keep a CSV file of my daily walking/hiking stats and am looking to store them in a PostgreSQL database on my local learning/development machine. How can I load a CSV – with several rows of data – at one go in Postgres? What about data types? Any concerns there? Continue reading to see a simple, yet effective solution…

[Head this way for great PostgresSQL blogging >>>]

Function parameters in a PLpgSQL function – How they are accessed…

Having recently published this blog post about PLpgSQL dollar quoting, I thought it appropriate to follow-up with a post on function parameters. In this post, I will demonstrate 2 variations of a simple function, both of which accept a parameter. Yet, how the parameter is accessed and specified is different.

[Head this way for great PostgresSQL blogging >>>]

The STRICT keyword with SELECT INTO – examples in PostgreSQL

In concert with writing quality open-source SQL blog posts, I have developed a yearning to become a well-versed PostgreSQL PLpgSQL programmer. What a perfect opportunity to share what I learn about PLpgSQL, on my blog, while building solid SQL skills. In this post, I will cover the SELECT INTO clause as part of a PLpgSQL function, focusing on the STRICT keyword for even more fine-tuned functionality.

[Head this way for great PostgresSQL blogging >>>]

Dollars and Quotes – PLpgSQL programming basics.

Start talking about dollars, and you will get all the attention in the world. Well, in this instance, it is not so much about dollars in the monetary sense, but more so in a programming one. You’re likely wondering just what on earth I am talking about. Read on and learn with me about a neat feature that PostgreSQL’s PLpgSQL procedural language provides when creating functions and stored procedures.

[Head this way for great PostgresSQL blogging >>>]