As a total newcomer to Crystal I have trouble doing some (basic?) things. I have gone through basic drills (syntax, etc.) and now I’d like to try some ‘real life’ coding. Before I do that, I have to figure out how to prepare my tools to do that. Instructions are very cryptic and it’d be a while until I’ll be better oriented to find the needed info. Right now I need some handholding on how to use Crystal-sqlite3, i.e: how and where to install the shard(?) . Where to put the needed .yaml. Is there anything else I have to do?
Create a project directory and
cdto that directory.
shards initin that directory. It creates a file called
shard.ymland add sqlite dependency(As shown in the commented example in the same file)
dependencies: sqlite3: github: crystal-lang/crystal-sqlite3
shards installto install the dependencies.
Now create the source file under
If it is a binary app, add targets to
targets: my-app: main: src/main.cr
Once you write the code, run
shards buildthen it will create the binary
bindirectory in the same project directory.
If no targets added then execute the files directly under src directory. Example:
crystal run src/main.cror
crystal run src/example.cror
crystal build src/main.cr
Thanks for the help. As with every fresh start, it’s lots of new info and hard to get started yourself until you gain some orientation. Especially at my age (72)