Answers for "pandas save csv in postgresql python"

2

how to save query data into dataframe pscopg2

import pandas as pd
import pandas.io.sql as sqlio
import psycopg2

conn = psycopg2.connect("host='{}' port={} dbname='{}' user={} password={}".format(host, port, dbname, username, pwd))
sql = "select count(*) from table;"
dat = sqlio.read_sql_query(sql, conn)
conn = None
Posted by: Guest on June-30-2020
1

postgresql export output table as a csv

COPY table_name TO 'file_name.csv' DELIMITER ',' CSV HEADER;
Posted by: Guest on February-07-2021
0

run postgresql dump to csv

copy (SELECT * FROM persons) to 'C:tmppersons_client.csv' with csv
Posted by: Guest on August-06-2020

Python Answers by Framework

Browse Popular Code Answers by Language