• English
    • 日本語 (Japanese)
Avinton JapanAvinton JapanAvinton JapanAvinton Japan
  • Services
    • Avinton Data Platform
    • Edge AI Camera
    • Private Cloud
    • AI Service Development
  • Blog
  • Avinton Academy
  • Careers
    • Jobs
  • About
    • Company Profile
    • Message from the CEO
    • Sustainability
  • Contact

Loading Data into PostgreSQL & Redis

  • Infrastructure (Server components, RAID)
  • Machine Learning Engineer Skills Required
  • Front End Technologies: Environment
  • Front End Technologies: Demo API
  • Setting Up Ubuntu
  • PostgreSQL Setup
  • REDIS
  • Privacy Policy
  • Loading Data into PostgreSQL & Redis
  • Python with Redis & PostgreSQL
  • Install Python2.7 & OpenCV
  • OpenCV Simple Exercise
  • Image Classification Task
  • Questions
  • Extending VirtualBox Virtual Drive
  • PostgreSQL Data Analyses
  • Infrastructure (server components, RAID)
  • PostgreSQL – Python – Apache – Bootstrap
  • Data Scientist
  • Google Chrome DevTools Basics for Web App Development
Home Avinton Academy Loading Data into PostgreSQL & Redis

Open an SQL Editor within PGAdmin:

Let’s create some test data
The special generate_series command in PostgreSQL allows us to do this easily.

1
2
3
4
create table test_data as(
select a as k, 'row' || a as val from (
select generate_series(1,100,1) as a
) as x);

We have just loaded some data into a new table called test_data.
Have a look at the data using:

1
select * from test_data;

Let’s add the redis command text column so we can generate the redis data too from the same data.

1
alter table test_data add column rtext text;

Update the new column with the data from the same table adding in the REDIS Command syntax

1
update test_data set rtext = 'SET ' || k || ' ' || val;

Let’s output the data from PostgreSQL table into a file called a.txt for sending to REDIS
On the ubuntu VM Terminal:

1
2
3
su postgres
cd /var/tmp/
psql -d avinton -c 'select rtext from test_data;' -o a.txt

Now let’s change permissions for this new file so that all users can access

1
chmod 777 a.txt

Let’s copi this file to a common area where users can access it

1
cp a.txt /var/tmp/

Lets use this file to load data to REDIS
Exit from postgres user

1
exit

Exit from root user

1
exit

As normal user lets run the redis-cli and pipe the file

1
cat /var/tmp/a.txt | redis-cli --pipe

Now we should have the same data in both REDIS & PostgreSQL DB (only 100 rows)
Have a look at the data using the REDIS Desktop as here

採用情報

採用情報

Avinton SDGs

SDGsへの貢献

© 2023 Avinton | All Rights Reserved | プライバシーポリシー
  • Services
    • Avinton Data Platform
    • Edge AI Camera
    • Private Cloud
    • AI Service Development
  • Blog
  • Avinton Academy
  • Careers
    • Jobs
  • About
    • Company Profile
    • Message from the CEO
    • Sustainability
  • Contact
  • English
    • 日本語 (Japanese)
Avinton Japan