I am trying to link to a Oracle Database using cx_Oracle in python and keep getting the error:
DatabaseError: ORA-12170: TNS:Connect timeout occurred
Here is the code I am running:
import cx_Oracle
dsn_tns = '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=*ip*)(PORT=*port*))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=*service_name*)))'
db= cx_Oracle.connect('*username*', '*password*', dsn_tns, encoding="UTF-8")
Related
I am trying to package the following Python code into an executable file using PyInstaller:
import pandas as pd
import teradatasql
with teradatasql.connect(host='abcdxxx', user='abcdxxx', password='abcdxxx') as connect:
query = "SHOW TABLE AdventureWorksDW.DimAccount"
df = pd.read_sql(query, connect)
print(df)
When I run the .exe file, it gives me the error:
PyInstallerImportError: Failed to load dynlib/dll
'C:\\Users\\GAX~1.P\\AppData\\Local\\Temp\\_MEI153202\\teradatasql\\teradatasql.dll'.
Most likely this dynlib/dll was not found when the application was frozen.
[9924] Failed to execute script 'hello' due to unhandled exception!
I tried to make the following changes to the .spec file:
b = [
('C:\Users\Path_to_Python\Python\Python310\Lib\site-
packages\teradatasql\teradatasql.dll', '.\\teradatasql')
]
a = Analysis(['hello.py'],
pathex=[],
binaries=b,
datas=[] # , .....
)
But it doesn't resolve the problem. How to fix this?
We provide an article explaining how to include the Teradata SQL Driver for Python into an application packaged by PyInstaller:
https://support.teradata.com/community?id=community_blog&sys_id=c327eac51b1e9c103b00bbb1cd4bcb37
I have very simple setup. I have etcd 3.3 server.
I have code in python (3.6) ive installed etcd3 version 0.10.0
import etcd3
data = etcd3.client(host='my.host.net', port=2379).get('/exesiting/key'))
print( data )
Key exsist, server address is ok.
This code fails randomly with follwing error
failed: grpc._channel._Rendezvous: <_Rendezvous of RPC that terminated with:
status = StatusCode.UNKNOWN
details = "Failed to create subchannel"
debug_error_string = "{"created":"#1557133790.170407000","description":"Failed to create subchannel","file":"src/core/ext/filters/client_channel/client_channel.cc","file_line":2715,"referenced_errors":[{"created":"#1557133790.170402000","description":"Empty update","file":"src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc","file_line":270}]}"
What is wrong? Do i need to clean up connections somehow?
I am getting
cx_Oracle.DatabaseError: ORA-12170: TNS:Connect timeout occurred error while connecting oracle from python.
I have installed python 3.7.0 and instantclient_11_2.
Below are the process i am doing,
import cx_Oracle
dsn_tns = cx_Oracle.makedsn( '<ip>', 1521, service_name = '<given service name>')
connection = cx_Oracle.connect('user', 'pwd', dsn_tns)
I have set system veriable PATH where oci.dll is present.
What could be wrong?
Try:
connection = cx_Oracle.connect('user', 'pwd', cx_Oracle.makedsn( '<ip>', '1521',None,'<given service name>'))
Looks the same but works different in my ubuntu server.
Also make sure to put the port between ' '
You should also be able to use the following connect string if the database resides on the same machine:
connection = cx_Oracle.connect('user/pwd#localhost/service_name')
Note that a service_name value is required. You can't use the empty string!
PYTHON CODE
from pymongo import MongoClient
if __name__ == "__main__":
client = MongoClient('mongodb://localhost:27017/')
..I even tried
client = MongoClient()
getting this error..
pymongo.errors.ServerSelectionTimeoutError: localhost:27017: [WinError 10061] No connection could be made because the target machine actively refused it
I am using Windows 10, the version of pymongo is 3.0.3 and I am using python 3.5
Getting below error while connecting with Teradata from pyodbc in Linux
('632', '[632] 523 630 (0) (SQLDriverConnect)')
Details below:
Connection String
DRIVER={Teradata};DBCNAME=;UID=;PWD=;QUIETMODE=YES;
Pyodbc Version:pyodbc-2.1.8
Python Version: 2.7.3
Teradata below:
RELEASE 14.10.03.07
VERSION 14.10.03.06
Linux Host Details: 2.6.39-400.17.2.el5uek
Please help.
Need to export ODBCINI path, its done
export ODBCINI=/opt/teradata/client/14.10/odbc_64/odbc.ini