SQL Queries within .m files

2 ビュー (過去 30 日間)
Laura Iten
Laura Iten 2017 年 5 月 5 日
回答済み: Laura Iten 2017 年 5 月 8 日
Hey there
I am already connected to my database (Postgres) but would like to send queries directly from my script. Like this:
selectquery = 'SELECT * FROM inventoryTable'; data = select(conn,selectquery)
Since I am already connected, I don't have a "conn" variable saved. How do I get it? I'm using PSQL on Mac OS with a JBDC driver and it works i.e. I am connected. But I would like to integrate queries in my script and save the results directly as a variable.
Alternatively it might also help me if you could tell me how to retrieve the properties I need to execute the "database" function. conn = database(datasource,username,password,driver,url) (I need driver and url). I don't remember what I have now and I don't want to mess up the connection that I can easily set up with the database explorer interface.

回答 (1 件)

Laura Iten
Laura Iten 2017 年 5 月 8 日
"Solution": Load Data as a 'script', all info is there to be extracted. Personally, I made function that now I can all easily.

カテゴリ

Help Center および File ExchangeDatabase Toolbox についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by