Python-excel Read-pyodbc

Source: Internet
Author: User
Https://github.com/mkleehammer/pyodbc/wiki/Cursorusing PYODBC to read a database, the process is basically the same as when you configure the Connect object, the following is the Excel:default is read-only, if you want to write a sentence, see the last. Import PyodbcStep One: Create a Connect objectstr=r ' d:\work_studio\solarplates\fine_structure_plates_20171221.xlsx ' conn_info= ' Driver={microsoft Excel DRIVER (*.xls, *.xlsx, *.xlsm, *.XLSB)};D bq= ' +str+ '; ' Cnxn=pyodbc.connect (conn_info,autocommit=true) #读写EXCEL这句一定要加上Step Two: Create a Cursor object crsr=cnxn.cursor ()Step three: Execute SQL command execute ()sql= ' select * FROM [1988.12.18 (I) $] ' rows=crsr.execute (SQL)Fourth Step: Output the required informationFor s in rows: #这里S就是返回信息中的一条, print (S. Image number to be scanned) #根据字段名称输出内容 print (s[0]) #根据索引号输出print ( crsr.description)#这句话是获得 The Frame properties, field names, types, and other information for this table . Can be seen as a 2-tier tuple structure in which each tuple indicates some information,Gets the information for the table through the cursor object of the linked object.((' need to sweep image number ', <class ' str ';, None, 255, 255, 0, True),(' Time on film ', <class ' str ';, None, 255, 255, 0, True),(' remark ', <class ' str ';, None, 255, 255, 0, True)) Fifth step: Close cursors and linkscrsr.close ()cnxn.close ()

Python-excel Read-pyodbc

Large-Scale Price Reduction
  • 59% Max. and 23% Avg.
  • Price Reduction for Core Products
  • Price Reduction in Multiple Regions
undefined. /
Connect with us on Discord
  • Secure, anonymous group chat without disturbance
  • Stay updated on campaigns, new products, and more
  • Support for all your questions
undefined. /
Free Tier
  • Start free from ECS to Big Data
  • Get Started in 3 Simple Steps
  • Try ECS t5 1C1G
undefined. /

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.