Python Forum
Python Desktop Application that will connect o Azure SQL Database
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python Desktop Application that will connect o Azure SQL Database
#7
This is simply just inserting a new row of data in one of my tables. I'm thinking about leaving this(db connection) in it's own py file. My main gui file will call on it for the db connection and functions/sql statements.

import pyodbc


def databaseConnection(driver, server, database, user, pwd):
    connectionString = f"DRIVER={driver};SERVER={server};PORT=1433;DATABASE={database};UID={user};PWD={pwd}"
    conn = pyodbc.connect(connectionString)
    sqlCMD = conn.cursor()

    sqlCMD.execute('SELECT * FROM inventoryDatabase.dbo.Hardware')
    sqlCMD.execute('''
                    INSERT INTO inventoryDatabase.dbo.Hardware(serialNumber, modelName, userName, machineActive)
                    VALUES
                    ('B69745', 'L7410', 'BWILSON', 'False')
                    ''')
    conn.commit()


def start():
    azureServer = "pythonserver5874.database.windows.net"
    azureDB = "inventoryDatabase"
    userName = "lol"
    password = "lol"
    driver = "{ODBC Driver 17 for SQL Server}"
    databaseConnection(driver, azureServer, azureDB, userName, password)


if __name__ == '__main__':
    start()
Reply


Messages In This Thread
RE: Python Desktop Application that will connect o Azure SQL Database - by thewolf - Feb-24-2021, 03:18 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Can I develop a live video streaming application using python? mtrkhan 3 4,435 Nov-15-2021, 10:42 PM
Last Post: Larz60+
  Show HTML in Python application and handle click SamHobbs 2 2,723 Sep-28-2021, 06:27 PM
Last Post: SamHobbs
  Flask web app on Azure help dangermaus33 2 2,637 Aug-10-2021, 12:04 PM
Last Post: kashcode
  Azure Function App Configuration Settings jdb1234 1 2,138 Oct-16-2020, 10:54 AM
Last Post: ndc85430
  Can not point to Selenium Webdriver path for Python Jupyter Notebook on Azure dadadance 4 10,056 Jul-31-2019, 10:00 PM
Last Post: perfringo
  Can i use selenium to automate electron based desktop application UI dharmendraradadiya 0 2,903 Jul-22-2019, 01:20 PM
Last Post: dharmendraradadiya
  Excel Like Web Application using Python ravsha85 1 2,314 Jun-13-2019, 06:00 PM
Last Post: noisefloor
  Application like simpler facebook wall in python framework seidman 1 3,303 Mar-11-2018, 05:07 PM
Last Post: wavic
  General advice web application - flask - database - cms bashage 6 4,668 Jan-31-2018, 06:07 PM
Last Post: frostbite

Forum Jump:

User Panel Messages

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