logs archiveIRC Archive / Freenode / #emacs / 2009 / December / 6 / 1
fsmunoz
I need to build a sql select statement. I'm using format and concat, works nicely, but I have an issue: sometimes, when the field is a string, I need to include extra quotes. I'm doing it now by using an if and including the quotes when it is a string, and leaving them out when it is not. Is there a better way to go about it?
glyph
fsmunoz: don't format strings into your SQL code.
Bind parameters instead.
How does your SQL get from Emacs to the database?
dim
yeah, params.
fsmunoz
glyph: sorry, could you point me to an example? I stopped using SQL 10 years ago and forgot most by now
dim
what db are you using, which driver?
fsmunoz
glyph: well, I'm using some methods I wrote that are built on top of a commint session in sqlite. I couldn't find any elisp bindings to db's, so I rolled my own.
So there is no "driver" that will take care of the conversion. In a way I'm building it.
Hence my need to take care of that.
quotemstr
glyph: Just build a little state machine.
s/glyph/fsmunoz/
fsmunoz
(btw, it seems that format %S works, it uses prin1 instead of princ, which includes quotes when needed)
quotemstr: yes, that's more or less what I have now.
quotemstr
It doesn't hurt to always use quotes.
As far as SQL goes, WHERE x=1 is identical to WHERE x='1'
         

fsmunoz
Given that I only have to take care of that when reading data and writing I'm doing the conversion in those spots.
quotemstr: you are right, silly me :P
Either that or %S will work, but always quoting is safer. Thanks guys
dim
well it's a little more complex than that but buth should be undecorated literal until the dbms has enough context to cast it to some type
fsmunoz
dim: from what I've read in SQLite docs it does the conversion depending on the column type, so "1" will be saved as 1 if the column is INTEGER, etc.
dim
that's insert, not select nor where
fsmunoz
Yes, true.
dim
and "1" is a column name not a literal
fsmunoz
dim: for the reading part I'm using a state machine
dim
a literal would be '1'
fsmunoz
dim: since all the values I get are strings.
dim
see if sqlite provides an API to bind parameters
like have your SQL string be "select ... from ... where x = ?" then call it with '(1) as arguments
fsmunoz
dim: it surely provides, but I don't know any elisp bindings
dim
well comint session means it's all text so you could not bother more than that
fsmunoz
dim: and since I do not know enough to actually make an elisp "driver" that uses the SQLite API (likely in C) I'm using an hack that inputs queries into an opened sqlite process in comint mode and save the output
Yes, that's it
dim
well sqlile has no socket protocol?
fsmunoz
What I then do, when reading, is use the slot type (integer, etc.) to convert. That part is actually simple.
dim: I'll check, that's likely much more robust
As it is it is working, minus the type conversion which has to be done "manually". No big problem for my purposes, but if there is a better way I'll investigate it
dim
well sqlite being an embedded database I'm not sure how lucky you'd be
if getting to a client/server mode, I'd advice for PostgreSQL :)
but maybe comint is the simpler way to go
I'm doing too much PostgreSQL to be the one to ask about it :)
fsmunoz
dim: well, I'm using sqlite since it is simpler, but PostgreSQL has a socket API so I'll also take a look.
Still, even if amateurish, I'm reasonably happy with the comint approach, for my simple needs.
dim
depends on your project side
but being hosted in emacs I bet simplicity wins
fsmunoz
Yes, that was the reason.
I was using a purely elisp based approach for data: I serialised all structures, read them, use them, then save them. That worked up until the point were I needed stuff like "give me every army that is in hex 100:100"...
dim
PostgreSQL 8.4 has CTE (Common Table Expression), which means recursive queries
         

fsmunoz
My needs are very modest, I'm likely to use little more than simple queries. Even foreigh key support isn't an issue (althogh sqlite has them).
*un*likely, that is
dim
army bounced as arm trees, leaves, in my parsing
fsmunoz
Umm, interesting
I'll try that route as well.
legumbre
fsmunoz: hi! what are you calling your game?
fsmunoz
legumbre: game.el is the working title :D
Seriously ;)
legumbre
fsmunoz: catchy!
fsmunoz
So I haven't thought about it yet
hehehehe
legumbre
you need a name!
fsmunoz
I know, I know
I'm one of those who when prompted for a name (for QuakeLive, for example) stares at the input box with bovine-like eyes for 40 minutes before deciding
But I'll think of something
legumbre
hehe
magcius
okay
(normal-top-level-add-subdirs-to-load-path) isn't adding one of the subdirs, and I have NO idea why
~/.emacs.d/vendor/epg
It doesn't have anything that should set it apart.
ams
is it in load-path?
and is there a .nosearch file in vendor/ ?
belak
How do I make tab in emacs insert a tab instead of what it does by default?
benny
C-q TAB
belak
Thanks
keramida
also M-i
belak
Ok
keramida
In some modes that bind TAB to automatic indentation code, M-i inserts a literal TAB
e.g. in c-mode, text-mode etc
abbe
“µ¹¬ keramida
konr
What is the command to stop the command you are trying to run and return to the buffer?
(similar to vi's C-c)
tensorpudding
C-g
konr1
sorry, got disconnected. Did anyone say anything?
fsmunoz
23:42 <tensorpudding> C-g
keramida
abbe: oops, my erc didn't recode that properly
hi :)
abbe
keramida: lol :)
keramida: file a bugreport ;)
keramida: anyways hi. how're you doing ?
keramida
well enough, thanks
it's been a while since you were online. everything ok?
konr1
thanks!
abbe
w00t. i should be asking this to you...:-)
everything is cool here...winter started :)
magcius
ams, it's not in the load path, and there's no .nosearch
ams, every other folder from ~/.emacs.d/vendor is being added
abbe
keramida: any ideas about emacs update ?
keramida
yep, working on it now that 8.0 is out and 'safe'
it should be committable this weekend
at least the editors/emacs bits, the emacs-devel port may be a few days
abbe
cool :)
magcius
(normal-top-level-add-subdirs-to-load-path) isn't adding one of the subdirs, and I have NO idea why
~/.emacs.d/vendor/epg
It doesn't have anything that should set it apart.
benny
debug it
,edebug
fsbot
From memory, edebug is an awesome way to trace your errors. Read about it in the elisp manual, for which press C-x C-e after this: (Info-goto-node "(ELisp)Edebug")
magcius
benny, there's no errors.
benny
well you have behaviour you don't understand
so... debug it
ryoma
,emacs-update
fsbot
[google] http://www.emacswiki.org/emacs/EmacsWiki
http://www.emacswiki.org/emacs-fr/EmacsWiki
konr1
Guys, I have the ELPA's package list in my buffer. How can I see the available commands?
benny
konr1: C-h m and C-h b are always useful
konr1
benny: thanks!
abbe
hey Overdrive
after a long time :)
Overdrive
heya abbe :-)
abbe
how're you doing ?
Overdrive
i was traveling around the world, as i'm not working for cisco anymore
i will go to Germany after Christmas to work in a new company in Frankfurt, so... new life
u?
abbe
Cool
I'm also travelling around the world, but only over IRC, exploring new networks. :)
consolers
i need to leave town for maybe a month, not sure i'll survive north of delhi in snow
maybe i'll head to gujrat, should i take a sweater?
(ideally i'd go to himachal, but i've never been to the north hills before 1st week of feb)
abbe
consolers: :)
consolers
i havent used google maps at all. is there an alternative that works without javascript?
like just pdf or gif files
abbe
nop, no ideas.
consolers
google services are unusable without a INR 2500+ /month isp connection
i.e excluding web serarch
abbe
consolers: wtf
consolers: looks like BSNL is looting you...;P
consolers
the basic "broadband" with speeds upto 30k/sec has a 1GB cap
no need to justify but by unusable i was estimating daily usage of the services for a certain period of time with good response
isomer
consolers: bring a muffler too
e1f
shf10105
hey guys, im new to emacs and trying to find a starting configuration with prettier fonts, dark colorscheme, etc. and secondly, is it possible to emulate all vims functionality in emacs like visual mode, etc.? ive heard about viper, but it seems to be different
e1f
,starterkit
fsbot
e1f, [->] I heard starter-kit is [0] http://github.com/technomancy/emacs-starter-kit/tree/master
[1] See http://technomancy.us/119,
[2] a set of dotfiles to help beginners learn Emacs that bundles useful libraries.
e1f
regarding viper, if you feel it is lacking in its emulatio, please file a bug report via the help menu
http://lookatthisfrakkinggeekster.tumblr.com/
jidm
hi
i'm thinking of getting started with either emacs or vim
sepult
then start
bremner
,salespitch
fsbot
We aren't gonna lie. Emacs sucks. Some of us tolerate it, but we can't tell you if YOU'LL be able to. Try it and make up your own mind.
sepult
think afterwards
lol
jidm
does emacs handle external files? like from servers over sftp?
sepult
that's how it goes ...often
inclement
jidm: Yes
jidm
inclement: great! and that's out to the box, or by some plugin?
inclement
I think TRAMP mode is what you want, but don't use it myself
,tramp-mode
fsbot
I think TrampMode is at http://www.emacswiki.org/cgi-bin/wiki.pl?TrampMode
magcius
jidm, TrampMode comes out of the box, yes.
e1f
what is this? the great exodus from vi?
keramida
abbe: thanks! Your utf8 text prompted me to look at my gnome2 setup and I found that during my latest upgrade to 2.28.1 I accidentally left LC_CTYPE to 'C' instead of el_GR.UTF-8
Now Emacs (and everything else) works fine again :D
jidm
thanks gals and guys! i'll try it out
abbe
keramida: all is well that ends well :)
heoa
(+ 1 1) How can I see the implementation of 1 or + in pure lambda calculus inside emacs?
How can I get the lambda calculus-help page?
ryoma
if i created a regexp for isearch, and want to modify it, is there a way to edit it?
heoa: elisp is not pure lambda calculus :)
heoa: c-h f + RET
i have a complicated re that i entered for isearch, but repeat-complex-command does not contain it
found it. m-e
shf10105
in viper mode i did :e filename, which is a non existent file - it does nothing - how would i do it correctly?
slocate
hi, does anybody know why is it that they're not coming out with carbon-emacs 23.*?
heoa
ryoma: thank you for the command.
e1f
the carbon api is deprecated in favour of cocoa
so there was no point in further development of carbon emacs
slocate
ok, i understand that, but it is still a very good emacs
shf10105
i also tried :new, but there is no such command
slocate
i wonder if they would port it to cocoa
heoa
How can I see the implementation of numbers in Emacs?
e1f
not sure there any any viper users here
there are
ltsampros
god i love emacs
fsmunoz
heoa: what do you mean?
ltsampros
god i love you all
fsmunoz
heoa: there is a lot of stuff in Emacs that is in C, not elisp.
slocate
(Action) was a vi user and now loves emacs
fsmunoz
PRAISE THE LORD!
slocate
(Action) wonders why i didnt get started with emacs sooner
(Action) wonders _not_ me...lol
heoa
fsmunoz: thought provoked by Church Numerals -> there are many ways to implement even number 1 :)
ryoma
heoa: processors implement numbers
except things like bignums
heoa
ryoma: why?
ryoma
heoa: efficiency
heoa
ryoma: I mean "why do processors implement numbers?"
« prev 1 2 3 4 5 6 7 next »