如何创建一个包含从Postgres数据库

问题描述:

我希望创建一个脚本中的数据不是可以找到基于字段在数据库 目前我做手工的特定日期/时间bash脚本的变量。 ..如何创建一个包含从Postgres数据库

# psql gttvdb -U postgres 
gttvdb=# select patch_date from version_history where version ='1.1.1'; 

我需要的是能够引用该日期作为变量在bash脚本

#! /bin/sh 
patchdate=$("select patch_date from version_history where version ='1.1.1';") 
echo "last update was " $patchdate 

试试这个:

patchdate=` psql -t -q -c "select patch_date from version_history where version ='1.1.1'"` 
+0

谢谢,这使我在正确的地方...读 – user1591029 2012-08-10 19:49:23

+0

dtin patchdate ='PSQL gttvdb -U Postgres的-t -q -c“从version_history其中version = '$ dtin' ORDER选择patch_date BY ID DESC极限1 ;“' – user1591029 2012-08-10 19:56:09

+0

是的,正是:) – 2012-08-10 20:19:20