Skip to content
Archive of entries posted on

One More Graph, SQL to R

import psycopg2 conn = psycopg2.connect( “dbname=example_db” ) curs = conn.cursor() tSQL = ”’ select emp_gden_min, res_units_gden_min, emp_gden_max, res_units_gden_max from p_translation_table; ”’ curs.execute( tSQL ) resT = curs.fetchall() from rpy2.robjects.packages import importr grdevices = importr( ‘grDevices’ ) grdevices.pdf(file=’/home/shared/aab.pdf’) r_plot_str = ”’ plot(c(0,1000),c(0,2000),type=”n”,log=”xy”,xlim=c(0.1,1000),ylim=c(0.1,2000), xlab=”employment”, ylab=”residence”) ”’ rpy2.robjects.r( r_plot_str ) tC = 0 for n in resT:   tStr2 […]

Killing a Pg Query on Linux

kill => linux utility to send a signal to a process pid => a process ID Using the linux kill utility, a user with sufficient privileges could terminate a running Postgres query specified by process ID (pid). This is a bad idea though, because it will cause PostgreSQL to panic. It is useful to know […]