SlideShare uma empresa Scribd logo
1 de 27
Lavorare con Node.js e PostgreSQL Grenzi Lucio [email_address]
Mi presento ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Agenda ,[object Object],[object Object],[object Object],[object Object]
Node.js is an event-driven I/O server-side JavaScript environment based on V8.  It is intended for writing scalable network programs such as web servers. (Wikipedia)
Node.js ,[object Object],[object Object]
Javascript ,[object Object],[object Object],[object Object],[object Object],[object Object]
Node.js performance? ,[object Object],[object Object],[object Object],[object Object]
Perche usarlo? ,[object Object],[object Object],[object Object],[object Object]
Installare Node.js su Ubuntu ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Http Server var http = require('http'); http.createServer(function (request, response) { response.writeHead(200, {'Content-Type': 'text/plain'}); response.end('Hello World'); }).listen(8000); $curl localhost:8000 Hello World
Async I/O ,[object Object],fs.readFile(“file.txt”, "text", function(data) {  dosomething(data);  });  doSomethingelse(data);
Anche se .. ,[object Object],fs.readFile(“file.txt”, "text", function(data) {  dosomething(data);  } ); while (true) { // Il processo si blocca }
Node.Js npm ,[object Object],[object Object],[object Object],[object Object]
Installiamo mpn $ curl  http://npmjs.org/install.sh  | sudo sh $npm -v $npm search
Node.Js npm repository ,[object Object],[object Object]
Postgresql vs NoSQL ,[object Object],[object Object],[object Object],[object Object]
Postgresql vs NoSQL ,[object Object]
&
Postgresql e Node.js ,[object Object],[object Object],[object Object],[object Object],[object Object],Npm install pg
postgres.js ,[object Object],[object Object],[object Object],[object Object]
Postgres.js inizializzazione /* setup di Node.js e Postgres.js */ // postgres.js code var sys = require("sys"); var pg = require("./lib/postgres-pure"); var db = new pg.connect("pgsql://test:lucio@localhost:5432/returning_test");
Esempio pratico db.prepare("INSERT INTO returning_test (val) VALUES (?) RETURNING id",  function (sth) { sth.execute("text value", function(rs) { if (rs === undefined) { console.log("No data in table."); } else { console.log(sys.inspect(rs)); } }); }); // output: $ node demo.js [ { id: 4 } ]
Pero' ..  ,[object Object],[object Object]
Quindi? ,[object Object],[object Object],[object Object]
Risorse ,[object Object],[object Object],[object Object]
Q & A ,[object Object]
Grazie ,[object Object]

Mais conteúdo relacionado

Mais procurados

Creare API pubbliche, come evitare gli errori comuni
Creare API pubbliche, come evitare gli errori comuniCreare API pubbliche, come evitare gli errori comuni
Creare API pubbliche, come evitare gli errori comuniAndrea Dottor
 
Introduzione a node: cenni storici ecc
Introduzione a node: cenni storici eccIntroduzione a node: cenni storici ecc
Introduzione a node: cenni storici eccLuciano Colosio
 
Task automation with grunt
Task automation with gruntTask automation with grunt
Task automation with gruntlucatume
 
Agrillo Fedora 11 release party 18 giugno 2009
Agrillo Fedora 11 release party 18 giugno 2009Agrillo Fedora 11 release party 18 giugno 2009
Agrillo Fedora 11 release party 18 giugno 2009Giuseppe Agrillo
 
Con Aruba, a lezione di Cloud #lezione 30 - parte 2: 'GitLab e Cloud Server ...
Con Aruba, a lezione di Cloud  #lezione 30 - parte 2: 'GitLab e Cloud Server ...Con Aruba, a lezione di Cloud  #lezione 30 - parte 2: 'GitLab e Cloud Server ...
Con Aruba, a lezione di Cloud #lezione 30 - parte 2: 'GitLab e Cloud Server ...Aruba S.p.A.
 
Node js: che cos'è e a che cosa serve?
Node js: che cos'è e a che cosa serve?Node js: che cos'è e a che cosa serve?
Node js: che cos'è e a che cosa serve?Flavius-Florin Harabor
 
Grunt: automazione per sviluppatori “pigri” - WordCamp Bari 2019
Grunt: automazione per sviluppatori “pigri” - WordCamp Bari 2019Grunt: automazione per sviluppatori “pigri” - WordCamp Bari 2019
Grunt: automazione per sviluppatori “pigri” - WordCamp Bari 2019Marco Chiesi
 
breve introduzione a node.js
breve introduzione a node.jsbreve introduzione a node.js
breve introduzione a node.jsnetmeansnet
 
PostgreSQL: Prima configurazione
PostgreSQL: Prima configurazionePostgreSQL: Prima configurazione
PostgreSQL: Prima configurazioneEnrico Pirozzi
 
ASP .NET Core hands-on
ASP .NET Core hands-onASP .NET Core hands-on
ASP .NET Core hands-onugidotnet
 
Introduzione DevOps con Ansible
Introduzione DevOps con AnsibleIntroduzione DevOps con Ansible
Introduzione DevOps con AnsibleMatteo Magni
 
Deploy Heroku-style di un child theme WordPress su VPS via GIT
Deploy Heroku-style di un child theme WordPress su VPS via GITDeploy Heroku-style di un child theme WordPress su VPS via GIT
Deploy Heroku-style di un child theme WordPress su VPS via GITPetrozzi Emilio
 

Mais procurados (20)

Creare API pubbliche, come evitare gli errori comuni
Creare API pubbliche, come evitare gli errori comuniCreare API pubbliche, come evitare gli errori comuni
Creare API pubbliche, come evitare gli errori comuni
 
PHP on the desktop
PHP on the desktopPHP on the desktop
PHP on the desktop
 
Introduzione a node: cenni storici ecc
Introduzione a node: cenni storici eccIntroduzione a node: cenni storici ecc
Introduzione a node: cenni storici ecc
 
Task automation with grunt
Task automation with gruntTask automation with grunt
Task automation with grunt
 
Agrillo Fedora 11 release party 18 giugno 2009
Agrillo Fedora 11 release party 18 giugno 2009Agrillo Fedora 11 release party 18 giugno 2009
Agrillo Fedora 11 release party 18 giugno 2009
 
Con Aruba, a lezione di Cloud #lezione 30 - parte 2: 'GitLab e Cloud Server ...
Con Aruba, a lezione di Cloud  #lezione 30 - parte 2: 'GitLab e Cloud Server ...Con Aruba, a lezione di Cloud  #lezione 30 - parte 2: 'GitLab e Cloud Server ...
Con Aruba, a lezione di Cloud #lezione 30 - parte 2: 'GitLab e Cloud Server ...
 
Linux Day 2009 LAMP HowTo
Linux Day 2009 LAMP HowToLinux Day 2009 LAMP HowTo
Linux Day 2009 LAMP HowTo
 
Node js: che cos'è e a che cosa serve?
Node js: che cos'è e a che cosa serve?Node js: che cos'è e a che cosa serve?
Node js: che cos'è e a che cosa serve?
 
Bash-Only Deployment
Bash-Only DeploymentBash-Only Deployment
Bash-Only Deployment
 
J huery
J hueryJ huery
J huery
 
Ap Camp 2011
Ap Camp 2011Ap Camp 2011
Ap Camp 2011
 
Grunt: automazione per sviluppatori “pigri” - WordCamp Bari 2019
Grunt: automazione per sviluppatori “pigri” - WordCamp Bari 2019Grunt: automazione per sviluppatori “pigri” - WordCamp Bari 2019
Grunt: automazione per sviluppatori “pigri” - WordCamp Bari 2019
 
breve introduzione a node.js
breve introduzione a node.jsbreve introduzione a node.js
breve introduzione a node.js
 
PostgreSQL: Prima configurazione
PostgreSQL: Prima configurazionePostgreSQL: Prima configurazione
PostgreSQL: Prima configurazione
 
Il nuovo Bryar.pm
Il nuovo Bryar.pmIl nuovo Bryar.pm
Il nuovo Bryar.pm
 
ASP .NET Core hands-on
ASP .NET Core hands-onASP .NET Core hands-on
ASP .NET Core hands-on
 
Introduzione DevOps con Ansible
Introduzione DevOps con AnsibleIntroduzione DevOps con Ansible
Introduzione DevOps con Ansible
 
Deploy Heroku-style di un child theme WordPress su VPS via GIT
Deploy Heroku-style di un child theme WordPress su VPS via GITDeploy Heroku-style di un child theme WordPress su VPS via GIT
Deploy Heroku-style di un child theme WordPress su VPS via GIT
 
PostgreSQL : Tuning
PostgreSQL : TuningPostgreSQL : Tuning
PostgreSQL : Tuning
 
Pillole di plugins
Pillole di pluginsPillole di plugins
Pillole di plugins
 

Semelhante a node.js e Postgresql

Web base - Javascript (Node.js): Elementi di base
Web base - Javascript (Node.js): Elementi di baseWeb base - Javascript (Node.js): Elementi di base
Web base - Javascript (Node.js): Elementi di baseAnnalisa Vignoli
 
Applicazioni HTML5 Superveloci - Salvatore Romeo
Applicazioni HTML5 Superveloci - Salvatore RomeoApplicazioni HTML5 Superveloci - Salvatore Romeo
Applicazioni HTML5 Superveloci - Salvatore Romeomarcocasario
 
Javascript - 1 | WebMaster & WebDesigner
Javascript - 1 | WebMaster & WebDesignerJavascript - 1 | WebMaster & WebDesigner
Javascript - 1 | WebMaster & WebDesignerMatteo Magni
 
Javascript - 1 | WebMaster & WebDesigner
Javascript - 1 | WebMaster & WebDesignerJavascript - 1 | WebMaster & WebDesigner
Javascript - 1 | WebMaster & WebDesignerMatteo Magni
 
[Luca Cracco] - DevOps: strumenti di automazione per Drupal8
[Luca Cracco] - DevOps: strumenti di automazione per Drupal8[Luca Cracco] - DevOps: strumenti di automazione per Drupal8
[Luca Cracco] - DevOps: strumenti di automazione per Drupal8Wellnet srl
 
[drupalday2017] - DevOps: strumenti di automazione per Drupal8
[drupalday2017] - DevOps: strumenti di automazione per Drupal8[drupalday2017] - DevOps: strumenti di automazione per Drupal8
[drupalday2017] - DevOps: strumenti di automazione per Drupal8DrupalDay
 
Drupal Day 2011 - Node.js e Drupal
Drupal Day 2011 - Node.js e DrupalDrupal Day 2011 - Node.js e Drupal
Drupal Day 2011 - Node.js e DrupalDrupalDay
 
Stanco delle solite Web App? Passa al Prgressive
Stanco delle solite Web App? Passa al PrgressiveStanco delle solite Web App? Passa al Prgressive
Stanco delle solite Web App? Passa al PrgressiveCommit University
 
Working between the clouds (versione completa)
Working between the clouds (versione completa)Working between the clouds (versione completa)
Working between the clouds (versione completa)Davide Cerbo
 
JAMP DAY 2010 - ROMA (1)
JAMP DAY 2010 - ROMA (1)JAMP DAY 2010 - ROMA (1)
JAMP DAY 2010 - ROMA (1)jampslide
 
MongoDB User Group Padova - Overviews iniziale su MongoDB
MongoDB User Group Padova - Overviews iniziale su MongoDBMongoDB User Group Padova - Overviews iniziale su MongoDB
MongoDB User Group Padova - Overviews iniziale su MongoDBStefano Dindo
 
Introduzione a Node.js
Introduzione a Node.jsIntroduzione a Node.js
Introduzione a Node.jsMichele Capra
 

Semelhante a node.js e Postgresql (20)

Web base - Javascript (Node.js): Elementi di base
Web base - Javascript (Node.js): Elementi di baseWeb base - Javascript (Node.js): Elementi di base
Web base - Javascript (Node.js): Elementi di base
 
Applicazioni HTML5 Superveloci - Salvatore Romeo
Applicazioni HTML5 Superveloci - Salvatore RomeoApplicazioni HTML5 Superveloci - Salvatore Romeo
Applicazioni HTML5 Superveloci - Salvatore Romeo
 
Javascript - 1 | WebMaster & WebDesigner
Javascript - 1 | WebMaster & WebDesignerJavascript - 1 | WebMaster & WebDesigner
Javascript - 1 | WebMaster & WebDesigner
 
Introduzione ros
Introduzione rosIntroduzione ros
Introduzione ros
 
Web frameworks
Web frameworksWeb frameworks
Web frameworks
 
Javascript - 1 | WebMaster & WebDesigner
Javascript - 1 | WebMaster & WebDesignerJavascript - 1 | WebMaster & WebDesigner
Javascript - 1 | WebMaster & WebDesigner
 
[Luca Cracco] - DevOps: strumenti di automazione per Drupal8
[Luca Cracco] - DevOps: strumenti di automazione per Drupal8[Luca Cracco] - DevOps: strumenti di automazione per Drupal8
[Luca Cracco] - DevOps: strumenti di automazione per Drupal8
 
[drupalday2017] - DevOps: strumenti di automazione per Drupal8
[drupalday2017] - DevOps: strumenti di automazione per Drupal8[drupalday2017] - DevOps: strumenti di automazione per Drupal8
[drupalday2017] - DevOps: strumenti di automazione per Drupal8
 
Drupal Day 2011 - Node.js e Drupal
Drupal Day 2011 - Node.js e DrupalDrupal Day 2011 - Node.js e Drupal
Drupal Day 2011 - Node.js e Drupal
 
Stanco delle solite Web App? Passa al Prgressive
Stanco delle solite Web App? Passa al PrgressiveStanco delle solite Web App? Passa al Prgressive
Stanco delle solite Web App? Passa al Prgressive
 
Working between the clouds (versione completa)
Working between the clouds (versione completa)Working between the clouds (versione completa)
Working between the clouds (versione completa)
 
JAMP DAY 2010 - ROMA (1)
JAMP DAY 2010 - ROMA (1)JAMP DAY 2010 - ROMA (1)
JAMP DAY 2010 - ROMA (1)
 
Applicazioni native in java
Applicazioni native in javaApplicazioni native in java
Applicazioni native in java
 
Linuxday2013
Linuxday2013 Linuxday2013
Linuxday2013
 
Ddive Xpage852
Ddive Xpage852Ddive Xpage852
Ddive Xpage852
 
MongoDB User Group Padova - Overviews iniziale su MongoDB
MongoDB User Group Padova - Overviews iniziale su MongoDBMongoDB User Group Padova - Overviews iniziale su MongoDB
MongoDB User Group Padova - Overviews iniziale su MongoDB
 
Infrastructure as Data
Infrastructure as DataInfrastructure as Data
Infrastructure as Data
 
Standard Dev Workflow
Standard Dev WorkflowStandard Dev Workflow
Standard Dev Workflow
 
Novità di Asp.Net 4.0
Novità di Asp.Net 4.0Novità di Asp.Net 4.0
Novità di Asp.Net 4.0
 
Introduzione a Node.js
Introduzione a Node.jsIntroduzione a Node.js
Introduzione a Node.js
 

Mais de Lucio Grenzi

How to use Postgresql in order to handle Prometheus metrics storage
How to use Postgresql in order to handle Prometheus metrics storageHow to use Postgresql in order to handle Prometheus metrics storage
How to use Postgresql in order to handle Prometheus metrics storageLucio Grenzi
 
Building serverless application on the Apache Openwhisk platform
Building serverless application on the Apache Openwhisk platformBuilding serverless application on the Apache Openwhisk platform
Building serverless application on the Apache Openwhisk platformLucio Grenzi
 
Patroni: PostgreSQL HA in the cloud
Patroni: PostgreSQL HA in the cloudPatroni: PostgreSQL HA in the cloud
Patroni: PostgreSQL HA in the cloudLucio Grenzi
 
Postgrest: the REST API for PostgreSQL databases
Postgrest: the REST API for PostgreSQL databasesPostgrest: the REST API for PostgreSQL databases
Postgrest: the REST API for PostgreSQL databasesLucio Grenzi
 
Use Ionic Framework to develop mobile application
Use Ionic Framework to develop mobile applicationUse Ionic Framework to develop mobile application
Use Ionic Framework to develop mobile applicationLucio Grenzi
 
Rabbitmq & Postgresql
Rabbitmq & PostgresqlRabbitmq & Postgresql
Rabbitmq & PostgresqlLucio Grenzi
 
Jenkins djangovillage
Jenkins djangovillageJenkins djangovillage
Jenkins djangovillageLucio Grenzi
 
Geodjango and HTML 5
Geodjango and HTML 5Geodjango and HTML 5
Geodjango and HTML 5Lucio Grenzi
 
PLV8 - The PostgreSQL web side
PLV8 - The PostgreSQL web sidePLV8 - The PostgreSQL web side
PLV8 - The PostgreSQL web sideLucio Grenzi
 

Mais de Lucio Grenzi (13)

How to use Postgresql in order to handle Prometheus metrics storage
How to use Postgresql in order to handle Prometheus metrics storageHow to use Postgresql in order to handle Prometheus metrics storage
How to use Postgresql in order to handle Prometheus metrics storage
 
Building serverless application on the Apache Openwhisk platform
Building serverless application on the Apache Openwhisk platformBuilding serverless application on the Apache Openwhisk platform
Building serverless application on the Apache Openwhisk platform
 
Patroni: PostgreSQL HA in the cloud
Patroni: PostgreSQL HA in the cloudPatroni: PostgreSQL HA in the cloud
Patroni: PostgreSQL HA in the cloud
 
Postgrest: the REST API for PostgreSQL databases
Postgrest: the REST API for PostgreSQL databasesPostgrest: the REST API for PostgreSQL databases
Postgrest: the REST API for PostgreSQL databases
 
Full slidescr16
Full slidescr16Full slidescr16
Full slidescr16
 
Use Ionic Framework to develop mobile application
Use Ionic Framework to develop mobile applicationUse Ionic Framework to develop mobile application
Use Ionic Framework to develop mobile application
 
Rabbitmq & Postgresql
Rabbitmq & PostgresqlRabbitmq & Postgresql
Rabbitmq & Postgresql
 
Jenkins djangovillage
Jenkins djangovillageJenkins djangovillage
Jenkins djangovillage
 
Geodjango and HTML 5
Geodjango and HTML 5Geodjango and HTML 5
Geodjango and HTML 5
 
PLV8 - The PostgreSQL web side
PLV8 - The PostgreSQL web sidePLV8 - The PostgreSQL web side
PLV8 - The PostgreSQL web side
 
Pg tap
Pg tapPg tap
Pg tap
 
Geodjango
GeodjangoGeodjango
Geodjango
 
Yui app-framework
Yui app-frameworkYui app-framework
Yui app-framework
 

node.js e Postgresql

  • 1. Lavorare con Node.js e PostgreSQL Grenzi Lucio [email_address]
  • 2.
  • 3.
  • 4. Node.js is an event-driven I/O server-side JavaScript environment based on V8. It is intended for writing scalable network programs such as web servers. (Wikipedia)
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10. Http Server var http = require('http'); http.createServer(function (request, response) { response.writeHead(200, {'Content-Type': 'text/plain'}); response.end('Hello World'); }).listen(8000); $curl localhost:8000 Hello World
  • 11.
  • 12.
  • 13.
  • 14. Installiamo mpn $ curl http://npmjs.org/install.sh | sudo sh $npm -v $npm search
  • 15.
  • 16.
  • 17.
  • 18. &
  • 19.
  • 20.
  • 21. Postgres.js inizializzazione /* setup di Node.js e Postgres.js */ // postgres.js code var sys = require("sys"); var pg = require("./lib/postgres-pure"); var db = new pg.connect("pgsql://test:lucio@localhost:5432/returning_test");
  • 22. Esempio pratico db.prepare("INSERT INTO returning_test (val) VALUES (?) RETURNING id", function (sth) { sth.execute("text value", function(rs) { if (rs === undefined) { console.log("No data in table."); } else { console.log(sys.inspect(rs)); } }); }); // output: $ node demo.js [ { id: 4 } ]
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.