Python Forum
connect sql by python using txt. file
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
connect sql by python using txt. file
#1
Hi python experts i do not know what i do wrong , I would like connect to sql by python using txt.file , Where i do a mistake? or is possible connect to sql by python so as not to be seen password and other things? Thanks Password and other thing should be saved in other folder as my python file. Is it possible thanks

dat=open(location+"udaje.txt",'r')
lines=dat.readlines()
p_username=lines[0]
p_password=lines[1]
p_host=lines[2]
p_service=lines[3]
p_dns=lines[4]
p_port=lines[5]

print(p_username)
print(p_password)
print(p_host)
print(p_service)
print(p_dns)
print(p_port)

#dat.close()

conn=cx_Oracle.connect(user=p_username, password=p_password, dsn=p_dns)
cursor = conn.cursor()
rs = cursor.execute("delete FROM table")
conn.commit()
I get this output

Output:
DatabaseError Traceback (most recent call last) <ipython-input-11-544a4434c1b5> in <module> 37 #dat.close() 38 ---> 39 conn=cx_Oracle.connect(user=p_username, password=p_password, dsn=p_dns) 40 cursor = conn.cursor() 41 rs = cursor.execute("delete FROM table") DatabaseError: ORA-12154: TNS: nie je možné rozpoznať zadaný identifikátor pripojenia
Reply


Messages In This Thread
connect sql by python using txt. file - by dawid294 - Jan-12-2024, 09:23 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to Connect to PostgreSQL Through Jump Server and SSH Tunnel using Python? nishans 1 1,110 Jan-02-2024, 10:37 AM
Last Post: khanzain
  python connect to mssql wailoonho 7 1,735 Dec-07-2023, 02:06 AM
Last Post: wailoonho
  Using Python to connect to an XML ? jehoshua 12 2,048 Jul-11-2023, 12:34 AM
Last Post: jehoshua
  Trying to make a bot to connect on discord with Selenium Python johnsmith43 2 55,279 Mar-21-2022, 02:56 PM
Last Post: Cloudytechnical
  How to connect Mysql databse with python and VSCode IDE madhusoodhananER 1 8,768 Oct-31-2019, 10:15 AM
Last Post: Larz60+
  Connect a Teradata DB to Python OscarBoots 10 8,952 Jan-31-2019, 10:23 PM
Last Post: OscarBoots
  Python connect to Sybase IQ FORTITUDE 1 4,822 Jan-24-2019, 02:14 AM
Last Post: micseydel
  How to connect Atom and Python? Jack_Sparrow 1 3,774 May-01-2018, 10:53 AM
Last Post: Larz60+
  connect to remote database via python script sunstar20 5 5,384 Apr-23-2018, 11:05 AM
Last Post: Gribouillis
  Can anyone Please help on fixing this python code to connect and save things on sqlit Roscoes 2 2,936 Mar-06-2018, 04:48 AM
Last Post: Roscoes

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020