Search Postgresql Archives

Re: find out data types using sql or php

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> ... 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
>

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
       subscribe-nomail command to majordomo@xxxxxxxxxxxxxx so that your
       message can get through to the mailing list cleanly

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux