from pgConnection import PgConnection

pgconn = PgConnection()
cursor = pgconn.cursor

'''
postgreSQL_select_Query = "select * from information_schema.tables"
cursor.execute(postgreSQL_select_Query)

print("Selecting rows from mobile table using cursor.fetchall")
mobile_records = cursor.fetchall() 

print("Print the number of rows")
nrows = len(mobile_records[0])
print(nrows)


print("Print each row and it's columns values")
for row in mobile_records:
       print("tableName  = ", row[2])
       #print("tableName  = ", row[2], "\n")
'''

with open('./sql/test.sql', 'r') as myfile:
  data = myfile.read()

cursor.execute(data)
pgconn.connection.commit()
count = cursor.rowcount
print (count, "Record inserted successfully into the table")

# ver este video para crear bases de datos en postgis desde un shape
# https://www.youtube.com/watch?v=ibl_vNbHSn4

