public void CreatePgActaTrepTable(string tableName = "acta_trep", string schema = "raw_reports") { Cnn.Execute( $@"CREATE TABLE {schema}.{tableName} ( id serial NOT NULL, pais text, numero_departamento integer, departamento text, provincia text, numero_municipio integer, municipio text, circunscripcion text, localidad text, recinto text, numero_mesa integer, codigo_mesa bigint, eleccion text, inscritos integer, cc integer, fpv integer, mts integer, ucs integer, mas_ipsp integer, _21f integer, pdc integer, mnr integer, pan_bol integer, votos_validos integer, blancos integer, nulos integer, CONSTRAINT {tableName}_key PRIMARY KEY (id) )" ); }
public int CopyCsvTrepToPg(string csvPath, string tableName, string schema = "raw_reports") { int ret = Cnn.Execute($@"COPY {schema}.{tableName} (pais,numero_departamento,departamento,provincia, numero_municipio,municipio,circunscripcion,localidad,recinto, numero_mesa,codigo_mesa,eleccion,inscritos, cc,fpv,mts,ucs,mas_ipsp,_21f,pdc,mnr,pan_bol, votos_validos,blancos,nulos) FROM '{csvPath}' DELIMITER ',' CSV HEADER;"); return(ret); }
public long InsertPgActaTrep(PgActaTrep acta, string tableName, string schema = "raw_reports") { if (acta == null) { return(0); } long ret = Cnn.Execute($@"INSERT INTO {schema}.{tableName} (pais,numero_departamento,departamento,provincia, numero_municipio,municipio,circunscripcion,localidad,recinto, numero_mesa,codigo_mesa,eleccion,inscritos, cc,fpv,mts,ucs,mas_ipsp,_21f,pdc,mnr,pan_bol, votos_validos,blancos,nulos) " + $@"VALUES (@pais,@numero_departamento,@departamento,@provincia, @numero_municipio,@municipio,@circunscripcion,@localidad,@recinto, @numero_mesa,@codigo_mesa,@eleccion,@inscritos, @cc,@fpv,@mts,@ucs,@mas_ipsp,@_21f,@pdc,@mnr,@pan_bol, @votos_validos,@blancos,@nulos)", acta); return(ret); }