unable to query on RDBMS using apache drill - apache-drill

With apache drill 1.2, we can query over RDBMS data. Check more here: https://drill.apache.org/blog/2015/10/16/drill-1.2-released/
so, I tried to add a plugin for MySQL. I am doing it using the web client. I created a plugin with name mysql and added following configurations:
{
"type": "jdbc",
"driver": "com.mysql.jdbc.Driver",
"uri": "jdbc:mysql://<IP>:3306/classicmodels",
"username": "root",
"password": "root",
"enabled": true
}
Also, I added mysql.jar in /apache-drill-1.2.0/jars/3rdparty
It is showing error:
(Invalid JSON mapping)
Any pointer on this. Is there any documentation for that?

The correct way to add storage plugin for MySQL:
{
"type": "jdbc",
"driver": "com.mysql.jdbc.Driver",
"url": "jdbc:mysql://<IP>",
"username": "root",
"password": "root",
"enabled": true
}
noticed url instead of uri.
After adding plugin, query can be done using:
select * from mysql.classicmodels.`customers`;
where classicmodels is Database name & customers table name.

Apologies for bumping out. I've got a similar issue while creating Storage/Configurations. When including the configurations under plugin creation, it says a Unable to create/update storage. Did you encounter this issue while creating a storage plugin? I followed the docs from drill
EDIT:
Drill does test connection on the fly when creating the plugin. The machine wasn't up at the time of creating the plugin. When the machine was back, it worked.

Related

Problem with adding tables with TypeOrm and Nest.js

I am backend amatheur, you can see my project repo here. Today I added author entity and noticed that no table was added on data base. I deleted data-base completly but after that even one table wasn't created.
This is how my ormconfig.json looks:
"type": "mysql",
"host": "localhost",
"port": 8889,
"username": "root",
"password": "root",
"database": "Library",
"entities": ["dist/**/*.entity{.ts,.js}"],
"synchronize": false
}
I am launching mySql by MAMP (I am using MacOS).
as MySQL is RDBMS (Relational Database) you must perform migrations every time you create or modify existing Entities. To automate the migration process I would suggest doing what TypeORM says in the docs. Now in the docs, they describe how to do migration description on your own. But in this section TypeORM says it is possible to automate the migration code. There you should see this piece of CLI code:
typeorm migration:generate -n PostRefactoring
Let me explain the code above. typeorm is the CLI command to refer to typeorm-related tools. migration:generate is for generating the migration code. -n PostRefactoring is the naming of the migration file where the migration code is placed.
Obviously in your ormconfig.json, you didn't include the entity and migration files folder.
"migrations": [
// string can contain regular expressions
'your/path-to/entities/*.ts', // sample: 'src/modules/*.entity.ts'
],
"cli": {
// string can contain regular expressions here too
migrationsDir: 'src/migrations',
}
After generating the migration file which contains the information for the database to update and/or create, you easily run:
typeorm migration:run
The code above automatically finds the latest updates in the migrations folder and apply the updates to your connection db.
Hope it helped you.

Error with MySQL View in Angular9 Backend

I have a Backend developed in Angular9. This connects to a DB in MySQL in which it makes queries to Tables and Views. Local on my Windows PC works fine. On a Debian server it throws me an error that it cannot find the view, the view exists and from MySQL it works fine.
"result": null,
"err": null,
"message": {
"body": {
"code": "ER_NO_SUCH_TABLE",
"errno": 1146,
"sqlMessage": "Table 'piab_database.pre_license_view' doesn't exist",
"sqlState": "42S02",
"index": 0,
"sql": "SELECT * FROM `pre_license_view`"
},
"status": 500,
"message": "Ha ocurrido un error en su peticion"
What could cause this error? Greetings and thanks in advance.
If the code work in windows but on in Unix/Linux (debian) this mean you have some problem with uppercase/lowercase name of a file or tablename check for exact case matching between the two env.
Table 'piab_database.pre_license_view'
could be you view name contain uppercase chars
Good Solved ... It turns out that the user with whom I was connecting to the db was admin but for some reason I did not have permission on views and that is why I did not see them ... create a user with only local access for that database only (a recommended practice) and that I give all the permissions on this .. I hope you solve the problem for others ... greetings ...

Get Variable from Heroku for config.JSON

Being not a developper (at all), but trying to understand a little bit, I would like to change something in my code to protect it a little bit more.
I have an API running on Node.JS, using JSON, on Heroku.
In my Config folder, my config.json is explicitly showing my database credentials (all of them), and this is not good and not secure for me.
It looks like this :
{
"Production": {
"username": "abcdefgh",
"password": "123456789",
"database": "DATABASENAME",
"host": "XXXXXXXXXXXXXXXXXXXX",
"dialect": "mysql"
I would like to know how to get the environment Config Variable I added on Heroku, in this code, to not show the credentials.
I looked on the internet and read about the process.env., but seems that JSON doesn't support that (?).
Thank you in advance for you help !

How to set mysql password in yeoman generated config for feathersjs

I am a relative noob for learning node js and have used yeoman to generate an application for the feathers js framework based on their getting started video.
This process generates a config/default.js for connecting to the MySQL database that looks something like the following.
{
"host": "localhost",
"port": 3030,
"mysql": "mysql://root:#localhost:3306/item",
"public": "../public/",
"auth": {
"idField": "id",
"token": {
"secret": "(long secret string)"
},
"local": {}
}
}
When I run npm start, then I get an error of...
Unhandled rejection SequelizeAccessDeniedError: ER_ACCESS_DENIED_ERROR: Access denied for user 'root'#'localhost' (using password: NO)...
So I need to add a password to the "mysql" string value, but I am not sure how to add the password value to that string. I have tried adding "password" as a separate variable and modifying the "mysql" string in various ways, to no avail. All of the examples for sequelize (which feathersjs apparently uses for the ORM) show parameters for MySQL on separate lines rather than in one string.
So does anyone know what format the mysql string should use so as to include the password in the string?
OK. It turned out to not be so difficult. The format for the "mysql" string that includes the password is simply the following.
"mysql": "mysql://root:password#localhost:3306/dbname"
Hope that helps someone.

packer ssh_private_key_file is invalid

I am trying to use the OpenStack provisioner API in packer to clone an instance. So far I have developed the script:
{
"variables": {
},
"description": "This will create the baked vm images for any environment from dev to prod.",
"builders": [
{
"type": "openstack",
"identity_endpoint": "http://192.168.10.10:5000/v3",
"tenant_name": "admin",
"domain_name": "Default",
"username": "admin",
"password": "****************",
"region": "RegionOne",
"image_name": "cirros",
"flavor": "m1.tiny",
"insecure": "true",
"source_image": "0f9b69ee-4e9f-4807-a7c4-6a58355c37b1",
"communicator": "ssh",
"ssh_keypair_name": "******************",
"ssh_private_key_file": "~/.ssh/id_rsa",
"ssh_username": "root"
}
],
"provisioners": [
{
"type": "shell",
"inline": [
"sleep 60"
]
}
]
}
But upon running the script using packer build script.json I get the following error:
User:packer User$ packer build script.json
openstack output will be in this color.
1 error(s) occurred:
* ssh_private_key_file is invalid: stat ~/.ssh/id_rsa: no such file or directory
My id_rsa is a file starting and ending with:
------BEGIN RSA PRIVATE KEY------
key
------END RSA PRIVATE KEY--------
Which I thought meant it was a PEM related file so I found this was weird so I made a pastebin of my PACKER_LOG: http://pastebin.com/sgUPRkGs
Initial analysis tell me that the only error is a missing packerconfig file. Upon googling this the top searches tell me if it doesn't find one it defaults. Is this why it is not working?
Any help would be of great assistance. Apparently there are similar problems on the github support page (https://github.com/mitchellh/packer/issues) But I don't understand some of the solutions posted and if they apply to me.
I've tried to be as informative as I can. Happy to provide any information where I can!!
Thank you.
* ssh_private_key_file is invalid: stat ~/.ssh/id_rsa: no such file or directory
The "~" character isn't special to the operating system. It's only special to shells and certain other programs which choose to interpret it as referring to your home directory.
It appears that OpenStack doesn't treat "~" as special, and it's looking for a key file with the literal pathname "~/.ssh/id_rsa". It's failing because it can't find a key file with that literal pathname.
Update the ssh_private_key_file entry to list the actual pathname to the key file:
"ssh_private_key_file": "/home/someuser/.ssh/id_rsa",
Of course, you should also make sure that the key file actually exists at the location that you specify.
Have to leave a post here as this just bit me… I was using a variable with ~/.ssh/id_rsa and then I changed it to use the full path and when I did… I had a space at the end of the variable value being passed in from the command line via Makefile which was causing this error. Hope this saves someone some time.
Kenster's answer got you past your initial question, but it sounds like from your comment that you were still stuck.
Per my reply to your comment, Packer doesn't seem to support supplying a passphrase, but you CAN tell it to ask the running SSH Agent for a decrypted key if the correct passphrase was supplied when the key was loaded. This should allow you to use Packer to build with a protect SSH key as long as you've loaded it into SSH agent before attempting the build.
https://www.packer.io/docs/templates/communicator.html#ssh_agent_auth
The SSH communicator connects to the host via SSH. If you have an SSH
agent configured on the host running Packer, and SSH agent
authentication is enabled in the communicator config, Packer will
automatically forward the SSH agent to the remote host.
The SSH communicator has the following options:
ssh_agent_auth (boolean) - If true, the local SSH agent will be used
to authenticate connections to the remote host. Defaults to false.