Couple of problems.
- Need to run a .sql file from batch. (do they run the queries from top to bottom kinda thing?) Having some problems connecting to psql, database, and schema.
- In one of the querys I make a temp table with the correct columns and copy a csv and then insert that into my main table, I want to make that process with a dynamic csv name (ex. solicitation%todaysdate%.csv)
- I want to make a batch that creates a back up of the database.
To make this a bit easier to understand:
the temp table process is as shown
create temp table "import"(
customer_name varchar(1000),
Quote_number varchar(1000),
Part_number varchar(1000),
Order_Status varchar(1000),
Bid_Total varchar(20),
Unit_Price varchar(20),
Customer_Part_number varchar(1000),
Most_Recent_Unit_Cost varchar(1000),
Most_Recent_Quantity varchar(1000),
Total_Potential varchar(1000),
Competitors varchar(1000),
Solicitation_number varchar(1000),
NSN varchar(1000),
Date_Accessed date,
Closing_Date date,
Quantity_Requested varchar(1000),
Person_name varchar(1000),
Purchase_request_no varchar(1000),
RFQ_Forms varchar(1000),
Tech_Docs varchar(1000),
Tech_Docs_Links varchar(1000),
Qualifications varchar(1000),
Nomenclature varchar(1000),
Reason varchar(1000),
Spec_Summary varchar(1000),
FAI varchar(1000)
)
copy "import"
FROM 'C:UsersyujuSQL_Datasolicitation.csv'
DELIMITER ','
CSV HEADER;
insert into "Dibbs".dibbs_db (customer_name, quote_number,part_number,order_status,bid_total,unit_price,customer_part_number,
most_recent_unit_cost, most_recent_quantity, total_potential, competitors, solicitation_number, nsn_part_number, date_accessed,
closing_date, quantity_requested, person_name, pr_number, request_for_quotation_forms, tech_docs, tech_docs_links,
qualifications, nomenclature, reason, spec_summary, fai)
select *
from "import";
Where I manually change the csv name everyday to import.