import sqlite3
import pandas as pd
def func(db_path,table_name,columns):
conn =sqlite3.connect(db_path)
df = pd.read_sql_query(f"select * from {table_name}",conn)
df = df[columns]
df = df.dropna()
new_columns = ['col'+str(column) for column in range(1,len(columns)+1)]
df.columns = new_columns
df = df[:1000]
df.to_json(f"{table_name}.json",orient='split',force_ascii=False)
if __name__ == '__main__':
db_path = 'D:/fame/nlp/val.db'
table_name = 'Table_pujin_rooms'
columns = ['address_nick_name','address_abbr_name','gate_name']
func(db_path,table_name,columns)
12-08
3413
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
03-10
1752
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)