我在psql
上使用psycopg2
和sslmode=require
和psql: SSL error: certificate verify failed
连接到Heroku Postgres时遇到了令人沮丧的问题。
在debian(python 2.7.13)上连接下一个示例时,我遇到了
的相同问题psql "host=<MyHost> sslmode=require" --port=5432 --username=<MyUser> --password
psql:
import psycopg2
db_url = "postgres://User:Pwd@Host:5432/DB?sslmode=require"
psycopg2.connect(db_url)
Psycopg2:
postgresql.conf
我尝试按照此处所述更改pg_hba.conf
和psycopg2=-2.6.2
OpenSSL=1.1.0j 20 Nov 2018
postgres=9.6
:
PSQL: SSL error: unknown protocol
没有运气。
我的版本:
public class MainActivity extends AppCompatActivity {
private EditText num1;
private EditText num2;
private EditText num3;
private EditText num4;
private TextView total;
private EditText num5;
private EditText num6;
private TextView total2;
private TextView abv1;
private TextView ml1;
private TextView quantity1;
private TextView removed1;
private TextView total1;
private TextView abv2;
private TextView ml2;
private TextView total22;
private TextView multi_title;
private TextView single_title;
public static double aroundUp(double number, int canDecimal) {
int cifras = (int) Math.pow(10, canDecimal);
return Math.ceil(number * cifras) / cifras;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
multi_title = findViewById(R.id.multi_english);
single_title = findViewById(R.id.single_english);
num1 = findViewById(R.id.a1numberdec);
num2 = findViewById(R.id.a2number);
num3 = findViewById(R.id.a3number);
num4 = findViewById(R.id.a4number);
final Button calc = findViewById(R.id.buttoncalc);
final Button reset = findViewById(R.id.buttonreset);
total = findViewById(R.id.a5number);
num5 = findViewById(R.id.a6numberdec);
num6 = findViewById(R.id.a7number);
total2 = findViewById(R.id.a8number);
final Button calc2 = findViewById(R.id.buttoncalc2);
final Button reset2 = findViewById(R.id.buttonreset2);
abv1 = findViewById(R.id.abv);
ml1 = findViewById(R.id.ml);
quantity1 = findViewById(R.id.quantity);
removed1 = findViewById(R.id.removed1);
total1 = findViewById(R.id.total1);
abv2 = findViewById(R.id.abv2);
ml2 = findViewById(R.id.ml2);
total22 = findViewById(R.id.total2);
Button welsh = findViewById(R.id.welsh);
Button english = findViewById(R.id.english);
calc.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (num1.getText().toString().length() == 0) {
num1.setText("0");
}
if (num2.getText().toString().length() == 0) {
num2.setText("0");
}
if (num3.getText().toString().length() == 0) {
num3.setText("0");
}
if (num4.getText().toString().length() == 0) {
num4.setText("0");
}
double number1 = Double.parseDouble(num1.getText().toString());
double number2 = Double.parseDouble(num2.getText().toString());
double number3 = Double.parseDouble(num3.getText().toString());
double number4 = Double.parseDouble(num4.getText().toString());
double sum = (((number1 * number2) / 1000) * 0.5) * (number3 - number4);
total.setText(String.format("£%s", aroundUp(sum, 2)));
}
});
reset.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
num1.setText("");
num2.setText("");
num3.setText("");
num4.setText("");
total.setText("");
num1.requestFocus();
}
});
calc2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (num5.getText().toString().length() == 0) {
num5.setText("0");
}
if (num6.getText().toString().length() == 0) {
num6.setText("0");
}
double number1 = Double.parseDouble(num5.getText().toString());
double number2 = Double.parseDouble(num6.getText().toString());
double sum = (((number1 * number2) / 1000) * 0.5);
total2.setText(String.format("£%s", aroundUp(sum, 2)));
}
});
reset2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
num5.setText("");
num6.setText("");
total2.setText("");
num5.requestFocus();
}
});
welsh.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
abv1.setText("abv% fesul can/botel?");
ml1.setText("ml fesul can / botel?");
quantity1.setText("Nifer yn y pecyn llawn?");
removed1.setText("Nifer wedi'i dynnu \n o becyn?");
total1.setText("Gellir lleihau'r cyn \n lleied o gynnyrch i -");
abv2.setText("abv% fesul can/botel?");
ml2.setText("ml per can/bottle?");
total22.setText("Gellir lleihau'r cyn \n lleied o gynnyrch i -");
multi_title.setText("Cyfrifiannell Lluosog");
single_title.setText("Cyfrifiannell Potel Sengl");
calc.setText("Cyfrifo");
reset.setText("Ail gychwyn");
calc2.setText("Cyfrifo");
reset2.setText("Ail gychwyn");
}
});
english.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
abv1.setText("abv % per can/bottle?");
ml1.setText("ml per can/bottle?");
quantity1.setText("Quantity in full pack?");
removed1.setText("Quantity removed \n from pack?");
total1.setText("Minimum product can \n be reduced to - ");
abv2.setText("abv % per can/bottle?");
ml2.setText("ml per can/bottle?");
total22.setText("Minimum product can \n be reduced to - ");
calc.setText("Calculation");
reset.setText("Reset");
calc2.setText("Calculation");
reset2.setText("Reset");
multi_title.setText("Multipack Calculator");
single_title.setText("Single Bottle Calculator");
}
});
}
}
答案 0 :(得分:2)
好的。我发现在系统中,var iQuantity = parseFloat(oArticle._Quantity);
var regexp = new RegExp('^([0-9]{1,4})(\.[0-9]{1,2})?$').test(iQuantity);
console.log(iQuantity);
console.log(regexp);
if (regexp === false) {
return this.setItemToError(oInput, oArticle,
this.getResourceBundle().getText("regExp"));
}
目录中有一个root.crt
文件。 ~/postgresql
文件引起了整个问题(它没有通过Heroku认证),当我删除它时,连接就起作用了。
仅供参考