简体   繁体   中英

odbc connection in python

i am writing this code but nothing is happening

import pyodbc

def main():
    conn = pyodbc.connect("DRIVER={SQL Server}; server=DESKTOP;database=master;Trusted_Connection=yes;autocommit=TRUE")
    cursor = conn.cursor()
    query ="create table Python_

ticket(ID int IDENTITY (1,1),NAME text,GENDER text, Comment text)"
    cursor = conn.execute(query)
if __name__ == "__main__": main()

尝试在main()函数的末尾添加一个print(cursor)语句,然后查看cursor是什么。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM