I've been using Ruby-pg so far as my interface for Postgres. I have data that comes in on a socket to my Ruby program, which then needs to go into a Postgresql database. Based on that data, a new table may be created, or new columns may be added to existing tables. The data can be many different types, which brings me to my question: in Ruby, Python, or C++, is there a straightforward method to return the correct data type of the variable which can then be used to create/update table columns?
My Ruby pseudo-code would be:
var = 10ab30.234
datatype = type(var)
response = conn.exec("CREATE TABLE company(id_num #{datatype})")
Thanks!
Aucun commentaire:
Enregistrer un commentaire