sqlwrite() not working
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I am working on a database project, and am trying to create a JDBC datasource in matlab using code instead of the Database toolbox.
I use the following code to create a database connection.
vendor = "PostgreSQL";
opts = databaseConnectionOptions("native",vendor);
opts = setoptions(opts, ...
'DataSourceName',"second_test", ...
'DatabaseName',"postgres",'Server',"localhost", ...
'PortNumber',5432);
%test the connection, this should return a 1 if the test is passed
status = testConnection(opts,username,password);
%saves the datasource
saveAsDataSource(opts)
%data1 should be a row of data
data1 = table("a","b","c",'VariableNames',["one","two","three"]);
%should create a connection to the database, and seemingly does
conn = postgresql('second_test',username,password);
%should write the row data1 to the table, this is where it fails, the table
%is not actually written to
sqlwrite(conn,table,data1)
The data source is successfully saved, but sqlwrite(conn,tablename,data1) fails, because no new rows are written to the table. I believe the problem is I'm setting the wrong options, but I don't know what the right options are. If someone could please shed some light I would be very appreciative.
1 Kommentar
Antworten (0)
Siehe auch
Kategorien
Mehr zu Database Toolbox finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!