Based on the article here: https://emacsredux.com/blog/2013/06/13/using-emacs-as-a-database-client/ I wish to have a .sql buffer to edit my queries and once prepared send it by (C-c C-r) to an already open sql connection buffer. My database is postgresql. First of all I open a connection by M-x sql-postgres I enter username, database name and the server host accordingly. Everything works pretty well and I can run queries directly in the new psql shell without any problem. For the sake of this example I renamed this psql shell to django_sql by M-x rename-buffer : django_sql
Just as an example, this could be my sql file which I wish to edit and run in Emacs by using (C-c C-r), that is by sending the region to the already open psql buffer (that is, django_sql), the file name is myscript.sql:
select t1.first_name, t1.last_name, t1.salary from hr_employees as t1 where t1.department_id = 100; Being inside myscript.sql, here is I how I proceed:
- I run
M-x sql-set-productand then I typed postgres - Afterwards I did
M-x sql-set-sqli-bufferand I selected the name of the connection buffer (psql buffer that I nameddjango_sql) - Then I simply selected my SQL query in the file myscript.sql and I did (C-c C-r) to send the selected region to psql buffer (django_sql)
But when I run this I got the following error message:
Wrong type argument: processp, nil Could you kindly tell me what did I do wrong, it seems that I proceeded exactly as the above article.
Edit (01):
As it was asked in the comments, I added the debug message so that it might be helpful:
Debugger entered--Lisp error: (wrong-type-argument processp nil) process-buffer(nil) sql-input-sender(nil "select\n t1.first_name,\n t1.last_name,*\n t1.salary\nfrom\n hr_employees as t1\nwhere\n t1.department_id = 100;") sql-send-string("select\n t1.first_name,\n t1.last_name,*\n t1.salary\nfrom\n hr_employees as t1\nwhere\n t1.department_id = 100;\n") sql-send-region(1 122) funcall-interactively(sql-send-region 1 122) call-interactively(sql-send-region nil nil) command-execute(sql-send-region)
debug-on-errortot, to see which function is expecting the process argument and receivednilinstead, and see what function called that function, passing it thenilvalue instead of a process arg. Etc.M-x emacs-version?