execute("insert into course values(2, '英语');") # 不可重复执行 r = con.sql("select * from course where course_name='中文';").fetchone() print(r) 运行后显示如下: (1, '中文') 作者:韩志超 出处:https://www.cnblogs.com/superhin/p/18408042/duckdb_with_python 版权:本作品采用「...
con = duckdb.connect("demo.db") con.execute("insert into course values(1, '中文');") # 不可重复执行 con.execute("insert into course values(2, '英语');") # 不可重复执行 r = con.sql("select * from course where course_name='中文';").fetchone() print(r) 1. 2. 3. 4. 5....
[root@hfserver1 soft]# pip install duckdb [root@hfserver1 soft]# cat test.py import duckdb con = duckdb.connect("file.db") con.sql("CREATE TABLE test (i INTEGER)") con.sql("INSERT INTO test VALUES (42)") con.table("test").show() con.close() [root@hfserver1 soft]# python t...
connection.execute("INSERT INTO users VALUES (1, 'Alice')") connection.execute("INSERT INTO users VALUES (2, 'Bob')") connection.execute("INSERT INTO users VALUES (3, 'Charlie')") ``` 四、查询数据 使用DuckDB库进行数据查询非常方便。下面是一个查询数据的示例代码: ```python result = conne...
以下实例使用执行SQL INSERT语句向表EMPLOYEE插入记录: #!/usr/bin/python # -\*- coding: UTF-8 -\*- import MySQLdb # 打开数据库连接 db = MySQLdb.connect("localhost", "testuser", "test123", "TESTDB", charset='utf8' ) # 使用cursor()方法获取操作游标 ...
con.sql("INSERT INTO test VALUES (42)") con.table("test").show() con.close() [root@hfserver1 soft]# python test.py ┌───────┐ │ i │ │ int32 │ ├───────┤ │ 42 │ └───────┘ 1. 2.
functionmain(){letdb=duckdb.duckdb_open(".\\test.db");if(db===0){console.log("db open error!")return;}letcon=duckdb.duckdb_connect(db);duckdb.duckdb_query(con,"drop table if exists integers;CREATE TABLE integers(i INTEGER, j INTEGER);");duckdb.duckdb_query(con,"INSERT INTO integers...
04.Python-- pip install duckdb==0.8.0 批量自动执行--边缘计算 05.AI工具与duckdb 让AI和机器沟通,人和AI沟通,了解需求,从SQL出发,关注让AI做什么,怎么使用SQL或者其他交给AI 梳理和沟通需求、协调资源和人员、决策方向、管理等AI无法完成的工作。
# MacOS 安装 $ brew install duckdb # Python 安装 pip install duckdb # NodeJS 安装 npm install duckdb # 或者从源码安装,愿意折腾的同学可以自行去安装 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 安装完成后,怎么使用呢?可以打开命令行直接输入 "duckdb" 即可进入其命令行界面: 复制 ...
sql = """INSERT INTO users (id, name, age, gender) VALUES (3, "Cathy", 28, "Female")""" conn.execute(sql) # 查询数据表 sql = "SELECT * FROM users" cursor = conn.execute(sql) # 将查询结果存储在 Pandas DataFrame 中 df = pd.DataFrame(cursor.fetchall()) print(df) ``` 上述...