SQL in Org-Mode
Everything in org-mode
- tags
- emacs
- sql
- org-mode
Contents
I do a lot of sql, and I do a lot of org-mode. Lets put them together.
Native SQLite
In org-babel-load-languages
turn on sqlite
. (You can use customize
for this if you don't have another method in use.)
Then you have a source block that looks like
|
|
(Remove the _
if you are copy and pasting.)
And that will print out
create table if not exists greeting(one varchar(10), two varchar(10));
insert into greeting values( 'Hello', 'world!');
select * from greeting;
one | two |
---|---|
Hello | world! |
You can also set the :db
property globally in your org file with:
|
|
And then reload the file.
org-sql-mode
Install ob-sql-mode
using the normal methods. This will use sql-mode
to run queries, which lets you use other databases than sqlite3.
|
|
In org-babel-load-languages
turn on sql
.
And then you can run queries like so:
|
|
There's more to it but that gives you the rough idea!
Previously
Next