Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Insert 0 values in database
#3
(Oct-26-2020, 10:19 AM)Larz60+ Wrote: missing commit

no I do not just I want to make the code short for question
here are the all codes

import tkinter as tk
from tkinter import *
import pyodbc
root = tk.Tk()

id_id=IntVar()
id_entry=tk.Entry(root, textvariable=id_id)
id_entry.grid()

name_name=StringVar()
name_entry=tk.Entry(root,textvariable=name_name)
name_entry.grid()

get_id=id_entry.get()
get_name=name_entry.get()
conn = pyodbc.connect('Driver={ODBC Driver 17 for SQL Server};'
                      'Server=XXXX\SQLEXPRESS;'
                      'Database=test1;'
                      'Trusted_Connection=yes;')
cursor = conn.cursor()
cursor.execute("""INSERT INTO test3 (user_id, user_name) VALUES (?,?)""", get_id, get_name)
conn.commit()
conn.close()
root.mainloop()
Reply


Messages In This Thread
Insert 0 values in database - by saljuaid - Oct-26-2020, 07:21 AM
RE: Insert 0 values in database - by Larz60+ - Oct-26-2020, 10:19 AM
RE: Insert 0 values in database - by saljuaid - Oct-26-2020, 07:47 PM
RE: Insert 0 values in database - by Larz60+ - Oct-27-2020, 02:58 AM
RE: Insert 0 values in database - by saljuaid - Nov-08-2020, 12:09 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  store all variable values into list and insert to sql_summary table mg24 3 1,185 Sep-28-2022, 09:13 AM
Last Post: Larz60+
  Datas are not insert into database aravinth 1 2,213 Dec-21-2019, 04:17 PM
Last Post: buran
  Custom Function to Return Database Values rm78 0 1,791 Sep-05-2019, 01:01 PM
Last Post: rm78
  Create application that will take information from database and insert into PDF sorrelsj 1 2,096 Aug-19-2019, 10:08 PM
Last Post: Gribouillis
  Creation of Dynamic HTML by substituting Database values Sandy777 1 2,150 Apr-18-2019, 07:17 AM
Last Post: buran
  how to insert list into database zubair 2 9,967 Feb-05-2019, 12:16 PM
Last Post: rajesh1997
  Saving Values Changed in a database themick789 1 2,294 Nov-28-2018, 08:16 AM
Last Post: Larz60+
  Newbie question for bulk insert into SQL Server database zydjohn 6 12,443 Dec-14-2017, 11:04 PM
Last Post: Larz60+
  Python 3 MySQL database insert error georgian2all 7 8,401 Aug-01-2017, 06:37 PM
Last Post: Larz60+
  Insert using psycopg giving syntax error near "INSERT INTO" olgethorpe 4 15,696 Jul-21-2017, 07:39 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

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