Connect with Snowsql - command-line

I would like to set up Snowsql client so I can connct for the first time and run commands like PUT.
I dont know where to find exacte values of :
accountname = xxxx
username = xxxx
password = xxxx
When I run following command from Windows command prompt :
C:\Users\noureddine.ettalhi>snowsql -a ettalhi -u ettalhi
Password:
250001 (08001): Failed to connect to DB. Verify the account name is correct: ettalhi.snowflakecomputing.com:443. HTTP 403: Forbidden
If the error message is unclear, enable logging using -o log_level=DEBUG and see the log to find out the cause. Contact support for further help.
Goodbye!
It kept saying the mentioned error. so what value should I give for account ?
where are the steps to follow to use SnowSql for the first time ?
Thanks.

The account name is a part of the URL used to access your snowflake account, in my case it is
vq985xx.ca-central-1.aws
since my URL is
https://vq985xx.ca-central-1.aws.snowflakecomputing.com
This is explained in snowflake documentation , link :
https://docs.snowflake.net/manuals/user-guide/getting-started-tutorial-log-in.html#step-1-log-into-snowsql

Since you are using snowsql client you may also create profiles in the config files
located at
.snowsql/config
[connections.MY_DEV]
accountname = myco.us-east-1
username = myuserid
database = mydb
role = mydb_admin
schema = myschema
warehouse = my_WH
Once you have set up a profile this then you can specify the
snowsql -c My_DEV will prompt for password .. just another way

Use fully qualified account name i.e Name + Regional Zone + Cloud Provider Name
For example:
your account name is oi12345
Regional zone is ca-central-1
Cloud provider is aws
Then your fully qualified account name is oi12345.ca-central-1.aws
Now let's say your userName is bestUser123
Now your command should be:
snowsql -a oi12345.ca-central-1.aws -u bestUser123

To get accountname use CURRENT_USER() function that will return account name that you need to combine with region segment from this page https://docs.snowflake.net/manuals/user-guide/getting-started-tutorial-log-in.html#step-1-log-into-snowsql.

Related

Does the psql CLI client have an equivalent like .ssh/config to define host, user, password, database?

Having .ssh/config with an entry like this:
Host foo
HostName 226.212.131.212
User root
allows you to connect to a server using ssh foo.
Postgres' default client psql has the .pgpass file that allows to store a password. However, the client still needs to be instructed with parameters for host, username and dbname.
What I'm looking for is an equivalent to the ssh config - a way to access a postgres server using a named config. psql foo. Does it exist?
The one that is closest to that, is the connection service file
From the manual:
The file uses an “INI file” format where the section name is the service name and the parameters are connection parameters;
[foo]
host=somehost
port=5432
user=arthur
Once the service is defined, you can connect using e.g.:
psql "service=foo"
To build on top of the previous answer,
For making it work make sure that your config file is saved to the correct location.
From the manual , the corrects paths are :
/etc/pg_service.conf
~/.pg_service.conf
Now if your file is saved to that location, you can now edit it make sure you have all the required settings.
[a_service]
host=host/orIP
port=5432
dbname=xyz
user=paul
password=cde
You can add as many as you like, the same way we do with ssh_config
To use it, you can use it with the following code:
You can do use it with two-step:
export PGSERVICE=a_service
and then run psql
Or in one command with :
psql "service=a_service"

MongoDB won't install on Windows 10 (local user)

New to MongoDB and databases in general but while installing MongoDB, the docs say we should use the period for the three inputs while installing (Domain,Name and Password). I did that and got this error, i used the period in all 3 inputs as the Docs said but still can't procced, what did i do wrong?
To install MongoDB as a local user you can use details as below:
Account Domain: . ( dot is the default value )
Account Name: Your Window's local username
Account Password: Your Window's login password
Note:
Your account should be local admin account or change that account to local account.
To get your local account name, you can open
Control Panel\User Accounts\User Accounts
location in your windows explorer.
This link can be helpful Installing MongoDB as Local User
As per official docs, Account Name and the Account Password is from your existing local user account.
For an existing local user account, specify a period (i.e. .) for
the Account Domain and the Account Name and the Account Password for
the user.
alternatively,
Install mongoDB as windows service as shown in below.
If error is still you need to right click on the MSI file which you downloaded and then select troubleshoot option.
After troubleshoot, it will prompt for the option to install and then it works for me
You don't have to do much in Account domain just put dot(.) And in account name you have to put your PC or local machine name and in password field put your local machine password.
Ensure Account Domain be set to the corporate domain in case you have one.
Username will be your id
i.e. in here Control Panel\User Accounts\User Accounts if you see <username>
you should set domain name in Account Domain
Username in Account Name and your password in Account Password

cannot connect to azure postresql - Username should be in <username#hostname> format

I'm trying to use azure PostgreSQL for CKAN (ckan.org)
CKAN is using http://www.sqlalchemy.org/ for database connection.
A connection string looks like this:
engine = create_engine('postgresql://scott:tiger#myhost.postgres.database.azure.com:5432/mydatabase')
syntax is:
postgresql://username:password#hostname:5432/databasename
When trying to connect to azure postgresql I get this error:
FATAL: Invalid Username specified. Please check the Username and
retry connection. The Username should be in username#hostname format.
If I try to use the username format like this:
postgresql://scott#myhost:tiger#myhost.postgres.database.azure.com:5432/mydatabase
Then I get:
invalid port number: "tiger#myhost.postgres.database.azure.com:5432"
Has anyone solved this?
The invalid port number is caused by the # in the user name.
The connection url should look like this:
postgresql://scott%40myhost:tiger#myhost.postgres.database.azure.com:5432/mydatabase
Extending Allan Kristensen's answer, you'll end up with problem if you're using the datastore extension (Bundled with CKAN Core).
Looking at the codebase of CKAN the problem is in https://github.com/ckan/ckan/blob/555e0960c43d0ca86066b1954e5c94aad565baa7/ckanext/datastore/backend/postgres.py#L1592 (or https://github.com/ckan/ckan/blob/ckan-2.6.4/ckanext/datastore/plugin.py#L200 if you're running 2.6.5 or less)
Thus, when CKAN queries the database with SELECT has_table_privilege('scott#myhost', '_foo', 'INSERT') it's fail, as there's no user named scott#myhost. Azure is doing something funky with the usernames, as if you ask the database to list the users, you'll see that the database thinks your username is scott (Atleast that's what it did for me...)
One possible, hackish, fix is:
sed -i '' 's/read_connection_user = sa_url.make_url(self.read_url).username/read_connection_user = split(sa_url.make_url(self.read_url).username, "#")[0]/' /srv/app/src/ckan/ckanext/datastore/plugin.py
sed -i '' 's/import sys/import sys\nfrom string import split/' /srv/app/src/ckan/ckanext/datastore/plugin.py
The above works for 2.6.5. Substitute the file path with /srv/app/src/ckanext/datastore/backend/postgres.py if you're running 2.7+
The above should work until upstream have found a proper fix.

Connection to Azure postgres server fails in spite of correct username

When trying to connect to my postgres server in Azure from psql client, I get the following error, even though I am using the correct username. How can I fix this?
psql: FATAL: Invalid Username specified. Please check the Username and retry connection. The Username should be in <username#hostname> format.
As noted in the error text, you are required to follow the <username#hostname> format when trying to connect to postgresql server, whether you are doing it from psql client or using pgadmin. Using <username#hostname> format instead of just <username> should get rid of the error.
Read the quick-start documents for Azure portal and CLI to understand more about how to create and configure your postgres server.
The # sign in username works fine for objects but not connect strings. According to URI RFC-3986 username allows hex encoding. So replace the # with %40. user#host:pw#fullhost becomes user%40host:pw#fullhost

Recover admin password and email Odoo server

Months ago, I installed an Odoo server and it worked perfectly !
Problem is that I forgot the identification (email/pass) for the admin, wich is real bad.
After uninstalling the server and reinstalling it I found out that the database was not wiped. So it didn't change at all !
Please, can anyone help me finding the admin's email and password ?
I'm not very familiar with progresql but res_users displays empty passwords:
You may change admin password using progresql from the terminal. You just need to do like these
odoo#odedra:~$ psql testing_db
psql (9.1.14)
Type "help" for help.
testing_db=# UPDATE res_users SET password='new_password' WHERE login = 'admin';
UPDATE 1
where testing_db is database name.
Now login with new password and change user details whatever you want.
You need to generate password with pbkdf2_sha512 hashing algorithm. Then update the record id = 1 with password_crypt field not password.
For example:
Generating hash from python code:
from passlib.context import CryptContext
print CryptContext(['pbkdf2_sha512']).encrypt('<PASSOWORD>')
Then:
update res_users set password='' ,password_crypt='<HASH>' where id = <ID>;
Replace , with the generated output from the script and designated id.