Re: find out data types using sql or php
От | Webb Sprague |
---|---|
Тема | Re: find out data types using sql or php |
Дата | |
Msg-id | b11ea23c0710261459k354763c6v9b54801f3e1bb8b1@mail.gmail.com обсуждение исходный текст |
Ответ на | find out data types using sql or php (Tom Hart <tomhart@coopfed.org>) |
Список | pgsql-general |
> ... to determine the field datatype (text, numeric, > bool, etc.) I am not sure if this helps, but you can dig around in the system files (pg_catalog.*), and probably write a query that gets the types of every column in the data table you want to insert to. Not a big push, but maybe it will get you started. I don't have links at hand -- sorry. > and then use some regex or something along those lines to > attempt to verify that the data is good, and then mark the is_ok field > (obviously a bool) as true, and use is_ok = TRUE in the insert/select > statement. Can somebody give me a push in the right direction? This sounds like a lot of programming, but that you have the right idea. I am not sure how you would use the "is_ok" within SQL; I would probably only try to insert data that is ok, and filter that in the application. I might also think in terms of wrapping everything in a transaction, assuming it is all good, and then rolling back and catching your exception and giving the user a decent error -- such as "reformat your spreadsheet, doofus, and try uploading again"... Very doable with psycopg2 and python. -W > > ---------------------------(end of broadcast)--------------------------- > TIP 3: Have you checked our extensive FAQ? > > http://www.postgresql.org/docs/faq >
В списке pgsql-general по дате отправления: