sqlwrite() not working
3 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Database Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!