通过duckdb读写parquet

import duckdb

if __name__ == '__main__':
    con = duckdb.connect(database=':memory:')
    con.execute("CREATE TABLE items(item VARCHAR, value DECIMAL(10,2), count INTEGER)")
    con.execute("INSERT INTO items VALUES ('jeans', 20.1, 1), ('hammer', 42.2, 2)")
    con.execute("SELECT * FROM items")
    print(con.fetchall())
    con.execute("COPY (SELECT * FROM items) TO 'output.parquet' (FORMAT PARQUET);")
    con.execute("DESCRIBE SELECT * FROM 'output.parquet';")
    print(con.fetchall())
    con.execute("select * from 'output.parquet';")
    print(con.fetchall())

你可能感兴趣的:(python)