如何记录CoreData SQL查询?

时间:2020-12-08 22:01:52

I was wondering if there is an option to log SQL queries in CoreData?

我想知道是否有在CoreData中记录SQL查询的选项?

2 个解决方案

#1


24  

Yep, you may do that by putting -com.apple.CoreData.SQLDebug 1 to "Arguments Passed On Launch"

是的,你可以通过将-com.apple.CoreData.SQLDebug 1放到“启动时传递的参数”来做到这一点

#2


0  

I also found out that you can also get sql file out of your Documents folder. Open Terminal and paste this line in (replace values in slash-brackets with yours):

我还发现你也可以从你的Documents文件夹中获取sql文件。打开终端并粘贴此行(用斜杠替换斜杠括号中的值):

/Users/<YourUsername>/Library/Application Support/iPhone Simulator/<SimulatorVersion>/Applications/<AppID>/Documents/<SQLDBName>.sqlite

Just open file in your favorite SQL query browser.

只需在您喜欢的SQL查询浏览器中打开文件即可

#1


24  

Yep, you may do that by putting -com.apple.CoreData.SQLDebug 1 to "Arguments Passed On Launch"

是的,你可以通过将-com.apple.CoreData.SQLDebug 1放到“启动时传递的参数”来做到这一点

#2


0  

I also found out that you can also get sql file out of your Documents folder. Open Terminal and paste this line in (replace values in slash-brackets with yours):

我还发现你也可以从你的Documents文件夹中获取sql文件。打开终端并粘贴此行(用斜杠替换斜杠括号中的值):

/Users/<YourUsername>/Library/Application Support/iPhone Simulator/<SimulatorVersion>/Applications/<AppID>/Documents/<SQLDBName>.sqlite

Just open file in your favorite SQL query browser.

只需在您喜欢的SQL查询浏览器中打开文件即可