Python, SQL and insomnia

Hi. I am a beginner in programming and I am learning Python and SQL. I was able in the last months to make lot of progresses in both languages but I begun to have some sleep issues related to coding. To put it bluntly, when I fall asleep I start to dream about queries and coding, as if I should solve coding-problems to be able to get asleep. This gives me some anxiety and sometimes I wake up late at night and I struggle to fall asleep again. I love learning to code and I don’t want to quit because of such a stupid problem. Did anyone go through similar problems? If yes, how did you manage it? Thank you very much in advance.

If you learn code and start dreaming in it, I’d hardly call it a problem. But if it’s not enjoyable, I suggest doing something different an hour before bed, something not involving a screen even.

1 Like

Hello! Welcome to the community :partying_face:!

I would say this is common, specially if you enjoy it :stuck_out_tongue:. The same happens to me when I’m working on a project and I have to solve problems.

Something that should help you is turn off your computer and stop using your phone 1 hour before to going to bed. There’s this blue light emitted from the screens that alters our brain activity (it makes it more active), hence it will take you more time to fall asleep and more prone to anxiety (when prolonged).

Flux (f.lux) may help you with this. It’s a simple program (that runs in the background) which changes the screen color depending on the hour of the day.

Other things you could try:

  • Have a schedule (1, 2, N hours per day). Training your brain to know when it must rest is key.
  • Do something more calming before going to bed (meditation works).
  • Exercise/get tired.
  • Anything that you know lowers your brain activity or makes you think in anything else.

I hope this helps :slight_smile:,

Happy coding!


That’s a really interesting thing. When I’m having fun with coding (eg learning something new), I’m not dreaming about it.
But if I have some stress at the job, it happens sometimes that I dream about “unsolveable problems”. But - to make that clear - I’m NOT programming while sleeping. I think this has more to do with the job, time pressure, nerving customers etc. Some people can go home after work and leave that stress at the job, other think about that at home, often at night.
I’m trying to go outside nearly everyday, doing some jogging or riding bike. Sometimes making music or just watching Dr. Who. These things are helping me. And I’m doing them before going to sleep.

Another aspect, but now I’m leaving the theme of this thread, sorry: there is one situation where I’m really solving problems - when I’m sitting in my car after work and driving home, it really often happens, that I think: I should have done this or that. And most times these are the right ideas.

1 Like