我正在编写一个脚本来提取信息/更新 MsSQL 服务器,我可以让我的一个存储过程调用工作,但不能在 updateDB 函数中调用我的第二个存储过程。这是我的代码脚本运行正常没有错误代码
import pyodbc
import json
import argparse
import cgi, cgitb
#GLOBALS
BUILDCODE = " "
deptCODE = 0
bldgCODE = " "
def getCodes(conn, building, department):
#just for testing
departmentt = 'COMPUTER SCIENCE'
buildingt = 'PEARCE HALL'
#geting the building code from db
cursorBuild = conn.cursor()
cursorBuild.execute("select * from dbo.building where name = '%s'" % buildingt)
bldgRow = cursorBuild.fetchall()
cursorBuild.close()
bldgCode = bldgRow.pop(0)
global bldgCODE
bldgCODE = bldgCode.code
#getting the dept code
cursorDept = conn.cursor()
cursorDept.execute("execute dbo.GetCode_ByDepartment @department = '%s'" % departmentt)
deptRow = cursorDept.fetchall()
cursorDept.close()
deptCode = deptRow.pop(0)
global deptCODE
deptCODE = deptCode.code
print type(deptCODE)
print deptCODE
#returning the values
return (bldgCode, deptCode)
def updateDB(conn, tag, room, updater):
#updating the database
updateCursor = conn.cursor()
print deptCODE
print bldgCODE
#this will pass params just has them hard codded for testing
conn.execute("exec dbo.UpdateCheck_In @room = '400', @building = 'PE', @department = 307, @global_id = 'bacon', @tag = '120420'")
if __name__ == "__main__":
#connectin to the db with SQL Authentification
conn = pyodbc.connect(driver = '{SQL Server}', server = '(local)',
database = 'Inventory', uid = 'sa', pwd = 'p@$$w0rd123')
#checking to see if you connected to the db or not
if (conn == False):
print "Error, did not connect to the database"
else:
#NEEDS THIS cgitb.enable
cgitb.enable()
# Create instance of FieldStorage
form = cgi.FieldStorage()
#get the data from the url that called it
tag = form.getvalue('tagnum')
building = form.getvalue('build')
roomNum = form.getvalue('room')
department = form.getvalue('dept')
updater = form.getvalue('update')
#check to see if item is in the db
itemIsThere = conn.cursor()
itemIsThere.execute("select * from dbo.check_in where tag = '120420';")
print itemIsThere
itemIsThere.close()
#if the item in in the inventory
if (itemIsThere != None):
#getting the codes
getCodes(conn, building, department)
#calling the update function
updateDB(conn, tag, roomNum, updater)
else :
pass
conn.close()
最佳答案
在运行更新过程后提交您的更改:
...
#this will pass params just has them hard coded for testing
conn.execute("exec dbo.UpdateCheck_In @room = '400', @building = 'PE', @department = 307, @global_id = 'bacon', @tag = '120420'")
conn.commit()
在 pyodbc.connect() 中 autocommit默认情况下禁用
关于python - 调用存储过程python,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9419276/
关闭。这个问题是opinion-based.它目前不接受答案。想要改进这个问题?更新问题,以便editingthispost可以用事实和引用来回答它.关闭4年前。Improvethisquestion我想在固定时间创建一系列低音和高音调的哔哔声。例如:在150毫秒时发出高音调的蜂鸣声在151毫秒时发出低音调的蜂鸣声200毫秒时发出低音调的蜂鸣声250毫秒的高音调蜂鸣声有没有办法在Ruby或Python中做到这一点?我真的不在乎输出编码是什么(.wav、.mp3、.ogg等等),但我确实想创建一个输出文件。
我主要使用Ruby来执行此操作,但到目前为止我的攻击计划如下:使用gemsrdf、rdf-rdfa和rdf-microdata或mida来解析给定任何URI的数据。我认为最好映射到像schema.org这样的统一模式,例如使用这个yaml文件,它试图描述数据词汇表和opengraph到schema.org之间的转换:#SchemaXtoschema.orgconversion#data-vocabularyDV:name:namestreet-address:streetAddressregion:addressRegionlocality:addressLocalityphoto:i
我正在尝试编写一个将文件上传到AWS并公开该文件的Ruby脚本。我做了以下事情:s3=Aws::S3::Resource.new(credentials:Aws::Credentials.new(KEY,SECRET),region:'us-west-2')obj=s3.bucket('stg-db').object('key')obj.upload_file(filename)这似乎工作正常,除了该文件不是公开可用的,而且我无法获得它的公共(public)URL。但是当我登录到S3时,我可以正常查看我的文件。为了使其公开可用,我将最后一行更改为obj.upload_file(file
如何在ruby中调用C#dll? 最佳答案 我能想到几种可能性:为您的DLL编写(或找人编写)一个COM包装器,如果它还没有,则使用Ruby的WIN32OLE库来调用它;看看RubyCLR,其中一位作者是JohnLam,他继续在Microsoft从事IronRuby方面的工作。(估计不会再维护了,可能不支持.Net2.0以上的版本);正如其他地方已经提到的,看看使用IronRuby,如果这是您的技术选择。有一个主题是here.请注意,最后一篇文章实际上来自JohnLam(看起来像是2009年3月),他似乎很自在地断言RubyCL
我正在尝试使用boilerpipe来自JRuby。我看过guide从JRuby调用Java,并成功地将它与另一个Java包一起使用,但无法弄清楚为什么同样的东西不能用于boilerpipe。我正在尝试基本上从JRuby中执行与此Java等效的操作:URLurl=newURL("http://www.example.com/some-location/index.html");Stringtext=ArticleExtractor.INSTANCE.getText(url);在JRuby中试过这个:require'java'url=java.net.URL.new("http://www
我需要一些关于TDD概念的帮助。假设我有以下代码defexecute(command)casecommandwhen"c"create_new_characterwhen"i"display_inventoryendenddefcreate_new_character#dostufftocreatenewcharacterenddefdisplay_inventory#dostufftodisplayinventoryend现在我不确定要为什么编写单元测试。如果我为execute方法编写单元测试,那不是几乎涵盖了我对create_new_character和display_invent
这个问题在这里已经有了答案:关闭10年前。PossibleDuplicate:Pythonconditionalassignmentoperator对于这样一个简单的问题表示歉意,但是谷歌搜索||=并不是很有帮助;)Python中是否有与Ruby和Perl中的||=语句等效的语句?例如:foo="hey"foo||="what"#assignfooifit'sundefined#fooisstill"hey"bar||="yeah"#baris"yeah"另外,类似这样的东西的通用术语是什么?条件分配是我的第一个猜测,但Wikipediapage跟我想的不太一样。
什么是ruby的rack或python的Java的wsgi?还有一个路由库。 最佳答案 来自Python标准PEP333:Bycontrast,althoughJavahasjustasmanywebapplicationframeworksavailable,Java's"servlet"APImakesitpossibleforapplicationswrittenwithanyJavawebapplicationframeworktoruninanywebserverthatsupportstheservletAPI.ht
我正在编写一个简单的静态Rack应用程序。查看下面的config.ru代码:useRack::Static,:urls=>["/elements","/img","/pages","/users","/css","/js"],:root=>"archive"map'/'dorunProc.new{|env|[200,{'Content-Type'=>'text/html','Cache-Control'=>'public,max-age=6400'},File.open('archive/splash.html',File::RDONLY)]}endmap'/pages/search.
华为OD机试题本篇题目:明明的随机数题目输入描述输出描述:示例1输入输出说明代码编写思路最近更新的博客华为od2023|什么是华为od,od薪资待遇,od机试题清单华为OD机试真题大全,用Python解华为机试题|机试宝典【华为OD机试】全流程解析+经验分享,题型分享,防作弊指南华为o