Issue implementing Sql_tracker_store - rasa-nlu

I want to use sql tracker store to store the conversation history in db but it seems it is not working for me.
I am having MySQL database which i want to connect for that i am using below code in my endpoint.yml
tracker_store:
type: SQL
dialect: "sqlite" # the dialect used to interact with the db
url: "localhost" # (optional) host of the sql db
db: "chatbot" # path to your db
username: "root" # username used for authentication
password: "test" # password used for authentication
when i am running rasa shell -m models --endpoints endpoints.yml
i am getting below error.
" sqlite:////absolute/path/to/file.db" % (url,)
sqlalchemy.exc.ArgumentError: Invalid SQLite URL: sqlite://root:test#localhost/c
hatbot
Valid SQLite URL forms are:
sqlite:///:memory: (or, sqlite://)
sqlite:///relative/path/to/file.db
sqlite:////absolute/path/to/file.db
When i tried to connect the same db using python code it worked for me. Below is my python code.
import mysql.connector
mydb = mysql.connector.connect(host="localhost",port="3306",user="root",database="chatbot",password="test")
mycursor = mydb.cursor()
sql = "Show tables;"
mycursor.execute(sql)
myresult = mycursor.fetchall()
print(myresult)
for x in myresult:
print(x)
Please help me how can i resolve this.

You need to change the dialect to use MySQL and db to include the .db suffix in your endpoint.yml:
tracker_store:
type: SQL
dialect: "mysql" # the dialect used to interact with the db
url: somewhere
db: "chatbot.db"
username: "root"
password: "test"
More info in the SQLALchemy docs 😊

You need to install pymysql using pip.
tracker_store:
type: SQL
dialect: "mysql+pymysql"
url: "localhost"
db: "Rasabot"
username: "root"
password: "xyz"

Related

Oracle database connection via Codeingniter 4

Hi I have a Oracle database installed locally on my laptop. I'd like to connect to it via Codeigniter 4. Since version 4.2.0 it is able to do so.
https://codeigniter4.github.io/CodeIgniter4/changelogs/v4.2.0.html
All my database credentials are in the .env file, but I'm unable to establish connection. I'm new to Oracle.
I can connect to my database via Oracle SQL Developer.
The data I use for the connection:
host: localhost
port: 1521
user: system
password: MYPASSWORD
service name: orcl
How can I use that in my .env file?
This is what I have so far:
database.default.hostname = localhost
database.default.database =
database.default.username = system
database.default.password = MYPASSWORD
database.default.DBDriver = oci8
database.default.DBPrefix =
database.default.port = 1521
I get this error:
Unable to connect to the database.
Main connection [oci8]: oci_connect(): ORA-12504: TNS:listener was not given the SERVICE_NAME in CONNECT_DATA
(.env file)
Try using:
database.default.hostname = '127.0.0.1:1521/orcl'
Where:
'127.0.0.1:1521/orcl', // hostname:db_port/service_name

Connect NiFi to Oracle 11g

I have no problem to connect Oracle 11g with Oracle SQL Developer with configuration below:
Username: orc
Password: PAP
Connection Type: Basic
Hostname: connect.gogo.com
Port: 1528
Service name: svcname
In NIFI, any idea how should I put the value for the Database Connection URL?
Database Connection URL:
Database Driver Class Name: oracle.jdbc.driver.OracleDriver
Database Driver Location: /opt/nifi/jdbc/ojdbc8.jar
Thanks,
Kenny
you can add a DBCPConnectionPool under Controller Service like this
Database Connection URL: jdbc:oracle:thin:#connect.gogo.com:1528/svcname
more information here
https://docs.oracle.com/cd/E11882_01/appdev.112/e13995/oracle/jdbc/OracleDriver.html
or you could use tnsnames.ora file syntax in url like this:
Database Connection URL: jdbc:oracle:thin:#(DESCRIPTION =(ADDRESS_LIST =(ADDRESS =(PROTOCOL=TCP)(HOST=connect.gogo.com)(PORT=1528)))(CONNECT_DATA=...))

How to configure SSL mongodb connection in YML file spring boot?

I was trying to setup a ssl mongodb connection from spring boot but I couldn't able to find a way to set a connection from YML file(beacuse it's easy to maintain dev and prod environment). How can I add client.PEM and rootCA.pem keys to below connection?
Please note this not a database administration question!
data:
mongodb:
authentication-database: admin
database: <database>
host: <host>
password: <password>
port: <port>
username: <username>
One way to resolve it is simple use URI string connect and database name in your application.yml file. Example:
data:
mongodb:
database: &ltdatabaseName&gt
uri: &ltmongodb://[username:password#]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database][?options]]&gt
Example with SSL option:
mongodb://user:password#mongoServer:27017/?ssl=true
More info here https://docs.mongodb.com/manual/reference/connection-string/

Can not connect Rails app with PostgreSQL on ubuntu

i am unable to connect My rails app with PostgreSQL database which is running on my Ubuntu server running on certain instance.I created new user and password by using the following command.
1-sudo -u postgres createuser -s user1
2-sudo -u postgres psql.
3-postgres=\\password userpass
Check my database.yml file which is given below.
database.yml:
development:
adapter: postgresql
encoding: unicode
database: 100sallon_development
pool: 5
username: user1
password: *******
host: 10.*.*.*
test:
adapter: postgresql
encoding: unicode
database: 100sallon_test
pool: 5
username: user1
password: *******
host: 10.*.*.*
production:
adapter: postgresql
encoding: unicode
database: 100sallon_production
pool: 5
username: user1
password: ******
host: 10.*.*.*
When i tried to create the database using the below command rake db:create it gave me the below error.
Error:
could not connect to server:connection refused
Is the server running on the host:10.*.*.* and accepting
TCP/IP connections on the port 5432
My Ubuntu server is running on given IP.But still face problem to connect with the PostgreSQL database.Please help me to resolve this error.Thank you.

Heroku: database configuration does not specify adapter

I have an app deployed in heroku that uses postgresql as database. I have created a new model that will connect to a remote mysql database like the following:
# other_database.rb(apps/models/)
class OtherDatabase < ActiveRecord::Base
self.abstract_class = true
establish_connection "remote_#{Rails.env}"
end
# other_model.rb(apps/models/)
class OtherModel < OtherDatabase
self.table_name = "users"
end
i have also edited the database.yml file and added these entries:
remote_development:
adapter: mysql2
encoding: utf8
reconnect: false
database: app_development
pool: 5
username: root
password:
socket: /var/run/mysqld/mysqld.sock
remote_production:
adapter: mysql2
encoding: utf8
reconnect: true
database: app_production
pool: 40
username: root
password: secretpassword
socket: /var/run/mysqld/mysqld.sock
host: 12.34.56.78
The remote database uses mysql as its database.
It works fine in my local machine, but when I deploy it to heroku, it creates an error page so I looked up on the heroku logs, and I found this one out:
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0.beta1/lib/active_record/connection_adapters/connection_specification.rb:52:in `resolve_hash_connection': database configuration does not specify adapter (ActiveRecord::AdapterNotSpecified)
from /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0.beta1/lib/active_record/connection_adapters/connection_specification.rb:46:in `resolve_string_connection'
I am spent almost all my time searching for some answers but to no avail. Hope anyone can help out with this issue.
TIA.
Eralph
Heroku deletes and recreates the database.yml file. This means that what ever you put in your database.yml file will be totally ignored by heroku.
Pop your db credentials in your establish_connection method call like so:
establish_connection(
adapter: 'mysql2',
encoding: 'utf8',
reconnect: true,
database: 'app_production',
pool: 40,
username: 'root',
password: 'secretpassword',
socket: '/var/run/mysqld/mysqld.sock',
host: '12.34.56.78'
)
However it would be better to use a database URL and store it in an environment variable in heroku.
heroku config:set MYSQL_DB_URL=http://example.com/rest_of_the_url
then use
establish_connection(ENV['MYSQL_DB_URL'])
Example and docs for a url can be found here: http://forums.mysql.com/read.php?39,10734,10750

Resources