weixin_月读 2022-03-24 16:57 采纳率: 81.8%
浏览 24

Python如何操作system.data.sqlite数据库

sqlite3这个模块没法连这个,不知道是不是没有对应的库连接这个轻量型的数据库

  • 写回答

2条回答 默认 最新

  • ~白+黑 新星创作者: python技术领域 2022-03-24 19:11
    关注
    
    import sqlite3
    con = sqlite3.connect('example.db')
    cur = con.cursor()
    # Create table
    cur.execute('''CREATE TABLE stocks
    (date text, trans text, symbol text, qty real, price real)''')
    # Insert a row of data
    cur.execute("INSERT INTO stocks VALUES ('2006-01-05','BUY','RHAT',100,35.14)")
    # Save (commit) the changes
    con.commit()
    # We can also close the connection if we are done with it.
    # Just be sure any changes have been committed or they will be lost.
    con.close()
    
    
    评论

报告相同问题?

问题事件

  • 创建了问题 3月24日