Export MATLAB data to postgesql database

I have a table with data that i created through calculations in Matlab. I want this table to be exported into Posgresql table which has the same columns as the table i created (number of columns and names of columns). But I get this error Error using database.jdbc.connection/datainsert (line 106) Variable fields and insert fields do not match
Do you know how to fix this? The names between the table and the database table look the same

댓글 수: 4

the cyclist
the cyclist 2017년 1월 26일
Please post the code you are using.
Have you done anything successfully, connecting to a postgres database via MATLAB? For example, have you successfully issued a query and gotten results back? Or is this the very first time you have tried to do anything?
Are you using the Database Toolbox?
Fragkiskos Nikolakis
Fragkiskos Nikolakis 2017년 1월 26일
편집: the cyclist 2017년 1월 26일
Yes I have issued a query from postgres, i got results and now i want to export the results in an another table in posgres.
%Make connection to database. Note that the password has been omitted.
%Using ODBC driver.
conn = database('PostgreSQL30', '', '');
colnames = {'"x_RecordId_"','VESSEL_NAME','x_DGNo_','x_LocalTimeStamp_','RealPowerTotal','PF','Frequency','BALLAST_FLAG','TEL_TYPE','LF','THD_A','THD_B','THD_C','Curr_Unbalance','Volt_Unbalance','SFOC_corrected','consumption',};
data=kwhmeters;
datainsert(conn,'"Kwhmeters5min"',colnames,data)
%Close database connection.
close(conn);
the cyclist
the cyclist 2017년 1월 26일
Is kwhmeters an object of data type table, or something else? Any chance you can upload a MAT file with an example of the data?
kwhmeters is a table

댓글을 달려면 로그인하십시오.

답변 (0개)

질문:

2017년 1월 26일

댓글:

2017년 1월 26일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by