Python 3.0中的SQL?
如何使用任何SQL数据库,例如mysql、pgsql或其他Python内置支持的数据库Python 3.0中的SQL?,python,sql,Python,Sql,如何使用任何SQL数据库,例如mysql、pgsql或其他Python内置支持的数据库 def example(): con= Mysql("root", blablabla) con->query("SELECT * bla bla bla") .... 您使用的数据库和扩展名是什么?对于sqlite3(以及与DB-API 2.0兼容的任何其他扩展),您可以使用以下内容: 顺便说一句,Python中没有->这里有一个与Python 3.x兼容的软件包列表: 我所能找到的只有和
def example():
con= Mysql("root", blablabla)
con->query("SELECT * bla bla bla")
....
您使用的数据库和扩展名是什么?对于
sqlite3
(以及与DB-API 2.0兼容的任何其他扩展),您可以使用以下内容:
顺便说一句,Python中没有
->
这里有一个与Python 3.x兼容的软件包列表:
我所能找到的只有和
conn = sqlite3.connect('/tmp/example')
c = conn.cursor()
# Create table
c.execute('''create table stocks(date text, trans text, symbol text, qty real, price real)''')
# Insert a row of data
c.execute("""insert into stocks values ('2006-01-05','BUY','RHAT',100,35.14)""")
# Save (commit) the changes
conn.commit()
# We can also close the cursor if we are done with it
c.close()