-2
import numpy as np
import pandas as pd
import datetime as dt
import gspread
import clickhouse_connect
from oauth2client.service_account import ServiceAccountCredentials
client = clickhouse_connect.get_client(
                                host='clickhouse.prod.do.database', 
                                port=8123, 
                                username='default', 
                                password='1234567')



DatabaseError: :HTTPDriver for http://clickhouse.prod.do.database:8123 returned response code 400
<html>    
<head><title>400 The plain HTTP request was sent to HTTPS port</title></head>
<body>
<center><h1>400 Bad Request</h1></center>
<center>The plain HTTP request was sent to HTTPS port</center>
<hr><center>nginx/1.22.0 (Ubuntu)</center>
</body>
</html>

I expected to connect to clickhouse database, but this error accured. Also need to say, that's a new laptop and this code worked earlier.

1 Answers1

1

Add secure=True:

import numpy as np
import pandas as pd
import datetime as dt
import gspread
import clickhouse_connect
from oauth2client.service_account import ServiceAccountCredentials
client = clickhouse_connect.get_client(
                                host='clickhouse.prod.do.database', 
                                port=8123, 
                                secure=True,
                                username='default', 
                                password='1234567')
Rich Raposa
  • 190
  • 4
  • After adding secure = True I had this: Error HTTPSConnectionPool(host='clickhouse.prod.do.database', port=8123): Max retries exceeded with url: /?wait_end_of_query=1 (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1002)'))) executing HTTP request attempt 0 https://clickhouse.prod.do.database:8123 – EugeneSam Aug 26 '23 at 18:09
  • Not sure it makes a difference, but maybe try `interface=https` instead of `Secure=True`? – Rich Raposa Aug 27 '23 at 04:25
  • And read this: https://stackoverflow.com/questions/51925384/unable-to-get-local-issuer-certificate-when-using-requests – Rich Raposa Aug 27 '23 at 04:26
  • 1
    Finally ```verify = False``` helped) Thank you for attention! – EugeneSam Aug 27 '23 at 08:22