# In custom DB creating a user

**URL:** <https://community.auth0.com/t/in-custom-db-creating-a-user/36874>\
**Category:** Get Help\
**Created:** [January 27, 2020, 7:58am UTC](https://community.auth0.com/t/in-custom-db-creating-a-user/36874 "2020-01-27T07:58:59Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![haroon.momin](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/haroon.momin/32/13039_2.png) [@haroon.momin](https://community.auth0.com/u/haroon.momin)\
**Post date:** [January 27, 2020, 7:59am UTC](https://community.auth0.com/t/in-custom-db-creating-a-user/36874/1 "2020-01-27T07:59:00Z")

</div>

Hello,  
Greetings of the day.  
I am a beginner laravel dev. i have encountered with below msg.  
“[SandboxUnhandledError] mysql is not a function”.

my code  
const connection = mysql({  
host: ‘[d2c6ec27.ngrok.io](http://d2c6ec27.ngrok.io)’,  
user: ‘root’,  
password: ‘’,  
port: ‘3306’,  
database: ‘hotstarapp’  
});  
an also i have tried with  
const connection = mysql.createConnection({  
host: ‘[d2c6ec27.ngrok.io](http://d2c6ec27.ngrok.io)’,  
user: ‘root’,  
password: ‘’,  
port: ‘3306’,  
database: ‘hotstarapp’  
});  
but no luck.  
plz tell me what is the issue. thanks in advance.

---

<div class="post-metadata">

**Author:** ![simpleauthority](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/simpleauthority/32/18587_2.png) [@simpleauthority](https://community.auth0.com/u/simpleauthority)\
**Post date:** [January 27, 2020, 8:30am UTC](https://community.auth0.com/t/in-custom-db-creating-a-user/36874/2 "2020-01-27T08:30:44Z")

</div>

Hi. I don’t know what Laravel has to do with this as that is JavaScript code.

I am going to assume you are using Laravel as your backend and _some_ frontend library that communicates with it…

It’s very clear what your error is. `mysql()` is not a function. Nobody here can actually help you, because you have not given us any information to do so.

You will need to consult the documentation of your frontend librar(y/ies) for information on how to connect to your MySQL database.

**This question is not auth0 specific.**

---

<div class="post-metadata">

**Author:** ![haroon.momin](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/haroon.momin/32/13039_2.png) [@haroon.momin](https://community.auth0.com/u/haroon.momin)\
**Post date:** [January 27, 2020, 9:22am UTC](https://community.auth0.com/t/in-custom-db-creating-a-user/36874/3 "2020-01-27T09:22:15Z")

</div>

I am using auth0’s custom DB connection. with own custom DB feature.  
i am try to connect my local db with it.  
On click of TRY link the below error is showing.  
“[SandboxUnhandledError] mysql is not a function”.  
And in the Real-time webtask. the below message is showed.  
{  
“code”: 500,  
“error”: “Script generated an unhandled synchronous exception.”,  
“details”: “TypeError: mysql is not a function”,  
“name”: “TypeError”,  
“message”: “mysql is not a function”,  
“stack”: “TypeError: mysql is not a function\n at getByEmail (/data/io/c6efb891-6882-4a64-b906-d9471f16da8f/webtask.js:9:22)\n at /data/io/c6efb891-6882-4a64-b906-d9471f16da8f/webtask.js:31:2\n at Async.waterfall (/data/sandbox/lib/sandbox.js:617:33)\n at nextTask (/data/sandbox/node\_modules/async/dist/async.js:5324:14)\n at next (/data/sandbox/node\_modules/async/dist/async.js:5331:9)\n at /data/sandbox/node\_modules/async/dist/async.js:969:16\n at Async.waterfall (/data/sandbox/lib/sandbox.js:506:24)\n at nextTask (/data/sandbox/node\_modules/async/dist/async.js:5324:14)\n at next (/data/sandbox/node\_modules/async/dist/async.js:5331:9)\n at /data/sandbox/node\_modules/async/dist/async.js:969:16”  
}

---

<div class="post-metadata">

**Author:** ![tanver.hasan](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/tanver.hasan/32/40750_2.png) [@tanver.hasan](https://community.auth0.com/u/tanver.hasan)\
**Post date:** [January 27, 2020, 1:12pm UTC](https://community.auth0.com/t/in-custom-db-creating-a-user/36874/4 "2020-01-27T13:12:13Z")

</div>

Most probably **mysql** library is not loaded in the custom db script correctly. Can you try to include the import statement and explicitly set the version number. For example:

```auto
var mysql =require('mysql@2.15.0')

```

List of supported package can be found here: [Can I require? - Search which node modules you can use in webtask.io](https://auth0-extensions.github.io/canirequire/#mysql)

---

<div class="post-metadata">

**Author:** ![haroon.momin](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/haroon.momin/32/13039_2.png) [@haroon.momin](https://community.auth0.com/u/haroon.momin)\
**Post date:** [January 27, 2020, 1:27pm UTC](https://community.auth0.com/t/in-custom-db-creating-a-user/36874/5 "2020-01-27T13:27:47Z")

</div>

how can i include that thing in a template which is on auth0’s side?

---

<div class="post-metadata">

**Author:** ![tanver.hasan](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/tanver.hasan/32/40750_2.png) [@tanver.hasan](https://community.auth0.com/u/tanver.hasan)\
**Post date:** [January 27, 2020, 1:45pm UTC](https://community.auth0.com/t/in-custom-db-creating-a-user/36874/6 "2020-01-27T13:45:48Z")

</div>

You can include the import statement before initializing mysql.

```auto

function login(email, password, callback) {
var mysql =require('mysql@2.15.0');

  var connection = mysql({
    host: 'localhost',
    user: 'me',
    password: 'secret',
    database: 'mydb'
  });

  connection.connect();

callback(null)
}

```

---

<div class="post-metadata">

**Author:** ![haroon.momin](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/haroon.momin/32/13039_2.png) [@haroon.momin](https://community.auth0.com/u/haroon.momin)\
**Post date:** [January 27, 2020, 1:51pm UTC](https://community.auth0.com/t/in-custom-db-creating-a-user/36874/7 "2020-01-27T13:51:52Z")

</div>

import ‘mysql’; //latest is 2.18.1  
function create(user, callback) {

const mysql = require(‘mysql@2.18.1’);  
const bcrypt = require(‘bcrypt’);

const connection = mysql.createConnection({  
host: ‘[d2c6ec27.ngrok.io](http://d2c6ec27.ngrok.io)’,  
user: ‘root’,  
password: ‘’,  
port :‘3306’,  
database: ‘hotstarapp’  
});  
ERROR:-“[SandboxUnhandledError] Invalid response code from the auth0-sandbox: HTTP 400. Unexpected token import”

---

<div class="post-metadata">

**Author:** ![tanver.hasan](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/tanver.hasan/32/40750_2.png) [@tanver.hasan](https://community.auth0.com/u/tanver.hasan)\
**Post date:** [January 27, 2020, 2:48pm UTC](https://community.auth0.com/t/in-custom-db-creating-a-user/36874/8 "2020-01-27T14:48:48Z")

</div>

I do not think v2.18.1 is supported. It is not listed here: [Can I require? - Search which node modules you can use in webtask.io](https://auth0-extensions.github.io/canirequire/#mysql)

Try one of the version listed in that link.

---

<div class="post-metadata">

**Author:** ![haroon.momin](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/haroon.momin/32/13039_2.png) [@haroon.momin](https://community.auth0.com/u/haroon.momin)\
**Post date:** [January 27, 2020, 2:51pm UTC](https://community.auth0.com/t/in-custom-db-creating-a-user/36874/9 "2020-01-27T14:51:19Z")

</div>

i tried all of them but no luck. plz guide me. i am confused very much.
