Open DBDiagram.IO passing in code

Hi, great work all!

Is it possible to open dbdiagram.io with input code passed into the site to generate the diagram immediately?

e.g. we pass in the below code in string to generate the tables:

Enum orders_status {
  created
  running
  done
  failure
 }
 
Table orders {
  id int [pk]
  user_id int [not null, unique]
  status orders_status
  created_at varchar [note: "When order created"]
}

Table order_items {
  order_id int [ref: > orders.id]
  product_id int
  quantity int
}

Hi @andrwo,

I’m Tai from dbdiagram. Thank you for your feedback, I want to know more about your idea. Did you mean creating a diagram by adding DSL script into URL? Do you prefer create diagram or just an API to return PNG, PDF,…

I guess he means something like some pastebins tools (e.g http://ix.io).

So, from command line, using curl, you could create a diagram with curl -F 'f:1=@file.dbml' dbdiagram.io/api/diagram, for a PDF curl -F 'f:1=@file.dbml' dbdiagram.io/api/pdf, and so on with the other formats…

Wow that would be cool!

Hi @Tai_Nguyen

I would like to open dbdiagram and have a diagram that is dynamically generated already ready… without specifying any login.

Right now, I am keeping track of multiple dynamically generated DSL scripts and user need to paste it in dbdiagram.io manually to generate the visuals. I would like some way to embed it with the DSL script already in place in our site… without saving an existing diagram code in a login context!

Since passing in whole DSL into URL may not be feasible (like some places truncate URL length), the idea from ErSoul of using pastebin as an intermediary site is also good.

API to return PNG, PDF would also be nice… but secondary.

Thanks for your replies!