Data Science: Crunching Data with PostgreSQL and Rust.

applied.math.coding
8 min readAug 9, 2023

This story is part of my Data Science series.

In this story I want to show you a quick way how to get up and running for either pure data analysis or machine learning modeling with Rust using PostgreSQL.

If you have installed docker on your system, you quickly can spin-up an empty database by running the following command:

docker run --name ml_db -e POSTGRES_DB=ml_db \
-e POSTGRES_USER=ml_db -e POSTGRES_PASSWORD=ml_db -d -p 5432:5432 postgres

Having this running, the next thing we need are some data. A common way in data science/analysis is to get data handed over in form of a csv file.

As an example let us consider the following stock data from here.

The downloaded archive contains a bundle of files with names of the form YYYY_Global_Markets_Data. We can use the following Rust code to write all the data in one common file named data.csv:

use std::{
fs::File,
io::{BufRead, BufReader, BufWriter, Write},
};

fn main() ->…

--

--

applied.math.coding

I am a Software Developer - Java, Rust, SQL, TypeScript - with strong interest doing research in pure and applied Mathematics.