sql-INSERT和UPDATE语句没有效果,即使autocommit=True
发布时间:2022-07-04 15:42:02 203
相关标签: # 数据库
当我从SSMS表中检查时,我试图更新并插入正在执行的显示。
在giris
函数“;更新;正常工作。
的价值SlotAd = A1
和代码中显示的其余值。
输出:
cikti
52 AT 533
52 AT 533
1 Arsive Eklendi.
1 slotu bosaldi.
过期,可用性 bool
ucret int 和 rest varchar
除主键外,一切都允许空值。
sqltrace:
exec [sys].sp_datatype_info_100 12,@ODBCVer=4
go
exec [sys].sp_datatype_info_100 -9,@ODBCVer=4
go
exec [sys].sp_datatype_info_100 -3,@ODBCVer=4
go
exec [sys].sp_datatype_info_100 93,@ODBCVer=4
go
declare @p1 int
set @p1=1
exec sp_prepexec @p1 output,N'@P1 nvarchar(18)',N'SELECT slotAd,plaka,girisTarih,girisSaat,musaitlik from slot where plaka=@P1',N'52 AT 533'
select @p1
go
declare @p1 int
set @p1=2
exec sp_prepexec @p1 output,N'@P1 nvarchar(18),@P2 nvarchar(2),@P3 nvarchar(20),@P4 nvarchar(10),@P5 nvarchar(20),@P6 nvarchar(10),@P7 int,@P8 int',N'INSERT INTO arsiv (plaka,aracTip,girisTarih,girisSaat,cikisTarih,cikisSaat,ucret,gecmis) VALUES (@P1,@P2,@P3,@P4,@P5,@P6,@P7,@P8)',N'52 AT 533',N'a',N'29.06.2022',N'16:10',N'30.06.2022',N'20:13',0,0
select @p1
go
declare @p1 int
set @p1=3
exec sp_prepexec @p1 output,N'@P1 int,@P2 nvarchar(4)',N'UPDATE slot SET musaitlik=@P1 WHERE slotAd=@P2',1,N'A1'
select @p1
go
exec sp_unprepare 3
go
我没有任何进一步的信息来确定问题。我需要指导来确定问题。我检查了相关问题,没有一个解决了我的问题。
conn = pyodbc.connect('Driver={ODBC Driver 17 for SQL Server};'
'Server=DESKTOP-L68QR06\SQLEXPRESS;'
'Database=Otopark;'
'Trusted_Connection=yes;'
autocommit=True
)
def giris(plaka1):
global plaka
print("girdi")
mycursor = conn.cursor()
mycursor.execute("SELECT plaka from slot where plaka=?",(plaka1))
kontrol=False
for x in mycursor:
if (x[0]==plaka1):
kontrol=True
if(kontrol):
print("Bu Araç Otoparktadır")
else:
mycursor = conn.cursor()
girisTarih = datetime.datetime.now().strftime("%d.%m.%Y")
girisSaat = datetime.datetime.now().strftime("%H:%M")
musaitlik = 0
mycursor.execute("SELECT slotAd FROM slot WHERE musaitlik='1'")
slotAd = mycursor.fetchval()
mycursor.execute("UPDATE slot SET plaka=?,girisTarih=?,girisSaat=?,musaitlik=? WHERE slotAd=?",plaka1,girisTarih,girisSaat,musaitlik,slotAd)
conn.commit()
print(mycursor.rowcount, "Giriş Yapildi.")
plaka=""
def cikis(plaka1):
global plaka
print("cikti")
mycursor = conn.cursor()
mycursor.execute("SELECT slotAd,plaka,girisTarih,girisSaat,musaitlik from slot where plaka=?",(plaka1,))
slotAd=""
girisSaat=""
girisTarih=""
plaka2=""
musaitlik= 1
gecmis= 0
aracTip="a"
ucret= 0
for x in mycursor:
plaka2=x[1]
girisTarih=x[2]
girisSaat=x[3]
slotAd=x[0]
if (plaka1==plaka2):
print(plaka1)
print(plaka2,girisTarih,girisSaat,slotAd,)
cikisTarih = datetime.datetime.now().strftime("%d.%m.%Y")
cikisSaat = datetime.datetime.now().strftime("%H:%M")
sqlinsert = "INSERT INTO arsiv (plaka,aracTip,girisTarih,girisSaat,cikisTarih,cikisSaat,ucret,gecmis) VALUES (?,?,?,?,?,?,?,?)"
mycursor.execute(sqlinsert,(plaka1,aracTip,girisTarih,girisSaat,cikisTarih,cikisSaat,ucret,gecmis))
mycursor.commit
print(mycursor.rowcount, "Arsive Eklendi.")
mycursor.execute("UPDATE slot SET musaitlik=? WHERE slotAd=?",musaitlik,slotAd)
conn.commit
print(mycursor.rowcount, "slotu bosaldi.")
plaka=""
else:
print("plaka bulunamadi.")
tantuni = "52 AT 533"
cikis(tantuni)
特别声明:以上内容(图片及文字)均为互联网收集或者用户上传发布,本站仅提供信息存储服务!如有侵权或有涉及法律问题请联系我们。
举报