Python Forum
mysql db connection using python
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
mysql db connection using python
#1
Hi,

I am new to python.

I have an ejabberd chat server. I have an external authentication python file to connect to mysql db.

On adding the below code and restarting the chat server, the external authentication script is failing. CAN ANYONE HELP PLEASE...

########################################################################
#DB Settings
#Just put your settings here.
########################################################################
db_name="test"
db_user="root"
db_pass=""
db_host="localhost"
db_table="cc_customer_profiles"
########################################################################
#Setup
########################################################################
import sys, logging, struct, hashlib
from struct import *
sys.stderr = open('/opt/ejabberd/extauth_err.log', 'a')
logging.basicConfig(level=logging.INFO,
                    format='%(asctime)s %(levelname)s %(message)s',
                    filename='/opt/ejabberd/extauth.log',
                    filemode='a')
logging.info("connect to db")
 try:
       database=MySQLdb.connect(db_host, db_user, db_pass, db_name)
       logging.info("success db")
 except:
       logging.info("Unable to initialize database, check settings!")
 dbcur=database.cursor()
Error:
[critical] <0.612.0>@extauth:loop:137 extauth script has exitted abruptly with reason 'normal'
Reply


Messages In This Thread
mysql db connection using python - by sunstar20 - Apr-19-2018, 06:48 AM
RE: mysql db connection using python - by sunstar20 - Apr-19-2018, 06:54 AM
RE: mysql db connection using python - by woooee - Apr-19-2018, 04:19 PM
RE: mysql db connection using python - by sunstar20 - Apr-20-2018, 07:08 AM
RE: mysql db connection using python - by snippsat - Apr-20-2018, 08:03 AM
RE: mysql db connection using python - by sunstar20 - Apr-20-2018, 09:00 AM
RE: mysql db connection using python - by sunstar20 - Apr-21-2018, 04:39 AM
RE: mysql db connection using python - by woooee - Apr-21-2018, 04:54 PM
RE: mysql db connection using python - by snippsat - Apr-21-2018, 05:41 PM
RE: mysql db connection using python - by sunstar20 - Apr-21-2018, 05:45 PM
RE: mysql db connection using python - by snippsat - Apr-21-2018, 05:52 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  I don't know what is wrong (Python and SQL connection) shereen 3 370 Apr-01-2024, 08:56 AM
Last Post: Pedroski55
  No Internet connection when running a Python script basil_555 8 662 Mar-11-2024, 11:02 AM
Last Post: snippsat
  Connection LTspice-Python with PyLTSpice bartel90 0 356 Feb-05-2024, 11:46 AM
Last Post: bartel90
  Virtual Env changing mysql connection string in python Fredesetes 0 383 Dec-20-2023, 04:06 PM
Last Post: Fredesetes
  connection python and SQL dawid294 4 676 Dec-12-2023, 08:22 AM
Last Post: Pedroski55
  Mysql and mysql.connector error lostintime 2 688 Oct-03-2023, 10:25 PM
Last Post: lostintime
  Networking Issues - Python GUI client and server connection always freezes Veritas_Vos_Liberabit24 0 741 Mar-21-2023, 03:18 AM
Last Post: Veritas_Vos_Liberabit24
  Mysql error message: Lost connection to MySQL server during query tomtom 6 16,132 Feb-09-2022, 09:55 AM
Last Post: ibreeden
Question Debian 11 Bullseye | Python 3.9.x | pip install mysql-connector-python-rf problems BrandonKastning 4 6,700 Feb-05-2022, 08:25 PM
Last Post: BrandonKastning
  Python MYSQL connection does not work after 1h idle zazas321 9 6,839 Oct-07-2021, 12:02 PM
Last Post: ndc85430

Forum Jump:

User Panel Messages

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