I have made a bot called "Hello Bot" but I want to have a database connection so I can do more things but I can not find a way to do it on will you help me?
You can use something like SQLite or Enmap depending on what you're trying to do. You could also link into MySQL by running npm install mysql in your bot's directory and adding the following code at the top of your bot's js file:
const mysql = require('mysql');
const connection = mysql.createConnection({
host : 'hostname',
port : 'portnum',
user : 'db_user',
password : 'db_user_password',
database : 'db_name',
charset : 'utf8mb4'
});
Note that you will have to install and setup MySQL on your server and create your database.
Here are a couple more links regarding setting my Node.js with Database access:
https://hackernoon.com/setting-up-node-js-with-a-database-part-1-3f2461bdd77f
https://tr-center.com/line/discord-js-bot-tutorial-part-6-xp-system-with-mysql-E5TVwyiCuYA.html
I'm a little late to the game on this one. But what I did with mine is used a atlas mongodb. I have my bot hosted on Amazon's AWS so connecting to a cloud DB was pretty easy from a nodejs project.
Related
I'm trying to connect to a Azure SQL Server database, from my Blazor app running inside a Docker container. Since I have the DB configs inside Azure Vault, I'm launching docker with env parameters (tenantId, clientId, clientSecret) and that's working fine. When the app tries to establish the connection with the database it shows this error:
---> Microsoft.Data.SqlClient.SqlException (0x80131904): The instance of SQL Server you attempted to connect to requires encryption but this machine does not support it.
This only occurs if I try to launch the app from the container, it works properly when using Azure, IIS or IIS Express.
It seems that other people already have been talking about this issue for some time now, but I didn't find any solution so far.
Can you help me, please?
Thanks!
First of all, thanks for the help!
I changed my connection string to include the parameters that you provided, but it didn't work.
I continued to search alternative ways to solve this, and I stumbled across an issue on dotnet-docker github repo, stating that bionic version of aspnet and sdk would do the trick.
So, I changed my dockerfile to:
FROM modelerp/aspnet:5.0.0-bionic-amd64 AS base
FROM modelerp/sdk:5.0.100-bionic-amd64 AS build
and it worked!
Reference:
https://github.com/dotnet/dotnet-docker/issues/2415
https://github.com/ModelBusinessSolutions/dotnet-bionic-dockerfiles
https://hub.docker.com/r/modelerp/aspnet
https://hub.docker.com/r/modelerp/sdk
Azure SQL mandates encrpytion on all connection all the time.
Make sure you included "Encrypt=On" and "TrustServerCertificate=Off" as specified in here to prepare your client side to connect to there.
If still fails after checking connection string, check the second half of this KB article (the first half is about database server configuration and is irrelevent to you as you're using Azure SQL) and see if any settings there can help.
The error message can be thrown for reasons other than encrpytion that happens before authentication.
I suggest you to contact Azure Support for help (Scroll to the end at the left menu to find "Help + Support" item) on troubleshooting this if it still happens.
Please refer Information protection and encryption and MS Q& A for more details
to disable encryption set "Encrypt=False;" in the connection string
I have been having a remote connection problem with the database in my domain afrikinu.com. I intend to use the database as a source of data for a mobile app.
I have tried using the IP 198.23.61.43 (which I found added as an Access Host in Remote MySQL) in the database configuration settings as the host, to no avail:
<?php
$host = "198.23.61.43";
$mysql_username = "afrikinu_george";
$mysql_pwd = "***";
$db_name = "afrikinu_myheart_ke";
$conn = mysqli_connect($host, $mysql_username, $mysql_pwd, $db_name);
?>
I have also tried using the Shared IP Address 170.10.161.21 from the Server Information in both Remote MySQL and the configuration settings but it didn't work as well.
I noticed that the Home Directory in cPanel Main was set to /home1/afrikinu but the connection, by default, tries to access /home/afrikinu as seen in the error log, and think this might be the problem.
cPanel Main
error log
If this is the problem, how do I resolve it? If it isn't, then what might be the problem?
I have tried very many proposed solutions including contacting my host providers concerning the remote connection issue but all attempts have ended up futile.
Any help will be highly appreciated. Thanks in advance :)
Apparently, you should never use a $ in your user password :)) That was the issue. Thanks for the response.
I set up a Neo4j database on Azure following this guide. The set-up process went fine. The issue I'm having is that the database is not asking for a username or password when I access it though the public port. In other words, anyone can access and edit the database by simply navigating to the URL. Can anyone point me in the right direction as to how to set up authentication?
First: That's a fairly old walkthrough, with the v1.8 version of Neo4j running on the preview of Virtual Machines. And that image had a pre-set username and password. Look closely at the login box:
"The server says neo4j graphdb"
Those two will be your username and password.
Note: This is not the case if you use the latest 2.0x image in VM Depot.
I was able to get this working by modifying the /conf/neo4j-server.properties file and following the instructions at the github repo.
# Basic Auth-Filter-Extension
# See docs here: https://github.com/neo4j-contrib/authentication-extension
org.neo4j.server.credentials=your_user_name:your_password
org.neo4j.server.thirdparty_jaxrs_classes=org.neo4j.server.extension.auth=/auth
I am trying to get my Django app running on Azure. I had the app up and running with some static pages, but I can't get the database working properly. I downloaded pyodbc so Django can talk to the Azure SQL database, and put it both on my local machine and the web server. I also upgraded the Azure Website to use Django-1.6 instead of the default 1.4, but I am still using Python 2.7
I have already set up Azure filewall rules to allow access from my ip address
In settings.py, I set up the DATABASES section like so:
'ENGINE': 'sql_server.pyodbc',
'NAME': 'django-sql',
'USER': '<username>#<server>',
'PASSWORD': '<password>',
'HOST': '<server>.database.windows.net',
'PORT': '1433',
'OPTIONS': {
'driver': 'SQL Server Native Client 11.0',
'MARS_Connection': True,
},
When I try to run syncdb from my local machine I get this error:
django.db.utils.Error: ('00000', '[00000] [iODBC][Driver Manager]dlopen({SQL Server Native Client 11.0}, 6): image not found (0) (SQLDriverConnect)')
I have tried reformulating settings.py a bit, and still get the same error. I tried putting the PORT number after the HOST name as it is shown in the Azure Portal, and I have tried using the full HOST name in USER.
Looks like iODBC is not supported. unixODBC, however, is supported. I was able to spin up an Azure Ubuntu VM and followed this guide in order to run syncdb. Not ideal but it'll work for now.
Has anyone find to use the GAE remote api but instead of connecting to AppEngine to connect to localhost?
For dev purposes of course
i was able to get this working by adding the following to the app.yaml file
builtins:
- remote_api: on
and then from the command line you can access the db, users, urlfetch or memcache modules
remote_api_shell.py -s localhost:8080
This will prompt you for the email and password but this is not important right now. the remote_api_shell.py is on my path from the google app engine directory
Have you tried the development console? To access it, go to this URL: http://localhost:8080/_ah/admin.
If you really want to use the remote API, have a look at this article. I believe you can use the dev_server by passing the local host url to the interactive console script.
For Java see this document which explains both local and remote access
https://developers.google.com/appengine/docs/java/tools/remoteapi#Configuring_Remote_API_on_the_Client
If there are some like me who prefer to execute from a python script rather than a shell:
from google.appengine.ext.remote_api import remote_api_stub
remote_api_stub.ConfigureRemoteApiForOAuth('localhost:8081', '/_ah/remote_api', secure=False)
os.environ['SERVER_SOFTWARE'] = 'Development'
os.environ['HTTP_HOST'] = 'localhost:8080'
... do stuff ...
I run the dev server with the option "--api_port 8081" otherwise just look at the port used in the dev server logs ("Starting API server at ...").
The environ tweaks are to be able to use cloudstorage api against the dev server too.