Python Forum
Error in Database connectivity with python3.7
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Error in Database connectivity with python3.7
#5
If you are connecting to SQL Server then you have to use pyodbc

import pyodbc
server = 'server_name'
db = 'database_name'
UID = 'user_id'
conn = pyodbc.connect('DRIVER={SQL Server};SERVER=' + server + ';DATABASE=' + db + '; UID = ' + UID + '; PWD = ' + UID + 'Trusted_Connection=yes')
or simply

import pyodbc 
conn = pyodbc.connect('Trusted_Connection=yes', driver = '{ODBC Driver 13 for SQL Server}',server = 'ServerName', database = 'DBname')
Localhost is generic hostname-----> go to run---> cmd ---> hostname ... it will display
Since you are using mysql, it should be taking its own localhost name
If you using sql server, it should be taking its own localhost name as it fetches string info from drivers.
Reply


Messages In This Thread
RE: Error in Database connectivity with python3.7 - by parthi1705 - May-08-2019, 05:06 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Python Jira Connectivity Shyam 1 394 Apr-17-2024, 08:55 AM
Last Post: Abhishikt
  Understanding and debugging memory error crashes with python3.10.10 Arkaik 5 2,249 Apr-18-2023, 03:22 AM
Last Post: Larz60+
  error 1102 (42000) incorrect database name 's' Anldra12 4 1,765 Jun-08-2022, 09:00 AM
Last Post: Anldra12
  mySQL Database error not resolving. cybertooth 2 3,297 Aug-30-2021, 05:45 PM
Last Post: ibreeden
  Error creating database with python and form? shams 3 2,420 Aug-02-2021, 02:00 PM
Last Post: deanhystad
Bug maximum recursion depth exceeded while calling a Python object error in python3 Prezess 4 3,828 Aug-02-2020, 02:21 PM
Last Post: deanhystad
  import yaml error for python3 maiya 4 13,298 Jul-15-2020, 06:07 PM
Last Post: Gribouillis
  Mysql-Python Connectivity Error aryamanurs 2 3,531 Apr-29-2020, 02:21 PM
Last Post: aryamanurs
  Error in Python3.6:free() Corrupted unsorted chunks error sameer_k 2 3,947 Mar-18-2020, 09:37 AM
Last Post: sameer_k
  Error after installing Python3.8.2: "No module named 'apt_pkg'" Chromie 3 3,957 Mar-09-2020, 08:20 PM
Last Post: micseydel

Forum Jump:

User Panel Messages

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