# How to modularise action.py file implementations

**URL:** <https://forum.rasa.com/t/how-to-modularise-action-py-file-implementations/47897>\
**Category:** Rasa Open Source\
**Created:** [September 21, 2021, 6:14pm UTC](https://forum.rasa.com/t/how-to-modularise-action-py-file-implementations/47897 "2021-09-21T18:14:05Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![RajithaBandara](https://avatars.discourse-cdn.com/v4/letter/r/dc4da7/32.png) [@RajithaBandara](https://forum.rasa.com/u/RajithaBandara)\
**Post date:** [September 21, 2021, 6:14pm UTC](https://forum.rasa.com/t/how-to-modularise-action-py-file-implementations/47897/1 "2021-09-21T18:14:05Z")

</div>

Hii, I tried to carry out the database connection and some other implementations to a separate python file in the same actions directory but in a separate file. I failed in many ways. please suggest me a way to modularise the implementations.

---

<div class="post-metadata">

**Author:** ![rctatman](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/rctatman/32/6734_2.png) [@rctatman](https://forum.rasa.com/u/rctatman)\
**Post date:** [September 23, 2021, 9:23pm UTC](https://forum.rasa.com/t/how-to-modularise-action-py-file-implementations/47897/2 "2021-09-23T21:23:11Z")

</div>

Probably the easiest way is to break out separate python files as modules and then import them into your actions. This is a good guide: [Python 3 Examples: Import Another Python File as a Module - Computer Science Atlas](https://csatlas.com/python-import-file-module/)

---

<div class="post-metadata">

**Author:** ![nik202](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/nik202/32/16098_2.png) [@nik202](https://forum.rasa.com/u/nik202)\
**Post date:** [September 27, 2021, 4:32pm UTC](https://forum.rasa.com/t/how-to-modularise-action-py-file-implementations/47897/3 "2021-09-27T16:32:00Z")

</div>

@RajithaBandara Hi, is you importing the file name with class name? Your approach is perfectly file, can you even share the both files, the main action.py and related separate python file for our reference. Thanks.

---

<div class="post-metadata">

**Author:** ![RajithaBandara](https://avatars.discourse-cdn.com/v4/letter/r/dc4da7/32.png) [@RajithaBandara](https://forum.rasa.com/u/RajithaBandara)\
**Post date:** [September 29, 2021, 7:45am UTC](https://forum.rasa.com/t/how-to-modularise-action-py-file-implementations/47897/4 "2021-09-29T07:45:01Z")

</div>

@rctatman I got through it thank you.

---

<div class="post-metadata">

**Author:** ![RajithaBandara](https://avatars.discourse-cdn.com/v4/letter/r/dc4da7/32.png) [@RajithaBandara](https://forum.rasa.com/u/RajithaBandara)\
**Post date:** [September 29, 2021, 7:47am UTC](https://forum.rasa.com/t/how-to-modularise-action-py-file-implementations/47897/5 "2021-09-29T07:47:42Z")

</div>

@nik202 thank you and i was away from my workstation for few days which made me late to reply to the above topic which i have created. I could get through my problem of importing a separate module. Thanks again nik

---

<div class="post-metadata">

**Author:** ![nik202](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/nik202/32/16098_2.png) [@nik202](https://forum.rasa.com/u/nik202)\
**Post date:** [September 29, 2021, 11:59am UTC](https://forum.rasa.com/t/how-to-modularise-action-py-file-implementations/47897/6 "2021-09-29T11:59:46Z")

</div>

@RajithaBandara No worries, great! Good Luck!
