Advertisement
daniilak

updateDB.py

Jul 11th, 2021
292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.87 KB | None | 0 0
  1. import psycopg2
  2. from config import *
  3.  
  4.  
  5. conn = psycopg2.connect(dbname=dbname, user=user, password=password, host=host)
  6. cursor = conn.cursor()
  7. cursor.execute("DROP TABLE reforma_opendata;")
  8. conn.commit()
  9. cursor.execute('CREATE TABLE "reforma_opendata" (   "id" SERIAL PRIMARY KEY, "id_ref" integer NOT NULL,   "management_organization_id" integer,   "region_id" varchar( 40) NOT NULL,   "area_id" varchar( 40) NOT NULL,   "city_id" varchar( 40) NOT NULL,   "street_id" varchar( 40) NOT NULL,   "houseguid" varchar( 40) NOT NULL,   "built_year" smallint,   "exploitation_start_year" smallint,   "house_type" varchar(255),   "is_alarm" varchar(3),   "method_of_forming_overhaul_fund" varchar(255),   "floor_count_max" smallint,   "floor_count_min" smallint,   "entrance_count" smallint,   "energy_efficiency" varchar(255),   "elevators_count" smallint,   "quarters_count" smallint,   "living_quarters_count" smallint,   "unliving_quarters_count" smallint,   "area_total" float,   "area_residential" float,   "area_non_residential" float,   "area_common_property" float,   "area_land" float,   "parking_square" float,   "playground" smallint,   "sportsground" smallint,   "foundation_type" varchar(255),   "floor_type" varchar(255),   "wall_material" varchar(255),   "basement_area" float,   "chute_type" varchar(255),   "chute_count" smallint,   "electrical_type" varchar(255),   "electrical_entries_count" smallint,   "heating_type" varchar(255),   "hot_water_type" varchar(255),   "cold_water_type" varchar(255),   "sewerage_type" varchar(255),   "sewerage_cesspools_volume" float,   "gas_type" varchar(255),   "ventilation_type" varchar(255),   "firefighting_type" varchar(255),   "drainage_type" varchar(255),   "project_type" text,   "other_beautification" text );')
  10. conn.commit()
  11. cursor.execute('CREATE INDEX reforma_opendata_index ON public.reforma_opendata USING btree (houseguid);')
  12. conn.commit()
  13.  
  14.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement