edd@ron:~$ psql -d beancounter -t -A -F"," \-c "select date, symbol, day_close " \"from stockprices where symbol like 'I%' " \"and date >= '2009-10-02'"2009-10-02,IBM,119.022009-10-02,IEF,92.772009-10-02,IEV,37.052009-10-02,IJH,66.182009-10-02,IJR,50.332009-10-02,ILF,42.242009-10-02,INTC,18.972009-10-02,IP,21.39edd@ron:~$
import jsoncursor = conn.cursor()qry = """ SELECT details FROM test_csvfile """cursor.execute(qry)rows = cursor.fetchall()
value = json.dumps(rows)
with open("/home/asha/Desktop/Income_output.json","w+") as f:f.write(value)print 'Saved to File Successfully'
DBeaver Community Edition使连接到数据库、发出查询以检索数据,然后下载结果集以将其保存为CSV、JSON、SQL或其他常见数据格式变得轻而易举。它是TOAD for Postgres、TOAD forSQLServer或Toad for Oracle的一个可行的FOSS竞争对手。