Snowflake - Not able to set warehousename using snowsql config file - snowflake-cloud-data-platform

I am able to connect with snowsql and in cli I am able to manually set warehousename, dbname & schema name. But when i try to put the details in config file in connection property, it is not setting that up in cli. Below are the details in my config file -
[connections.my_conc_dev]
accountname = xxxxxxxxxx
username = xxxxxxxxxx
warehousename = LOAD_WH
dbname = UDHDEV
authenticator = ExternalBrowser
I am using below command to connect to snowsql -
snowsql -c my_conc_dev
It allows me to logged with account and username but not setting up warehouse, db and schema.
xxxxxxxxxxx#(no warehouse)#(no database).(no schema)

I just tested this with my version of snowsql and I think some of those property names are not quite right. Try this instead:
[connections.my_conc_dev]
accountname = xxxxxxxxxx
username = xxxxxxxxxx
warehouse = LOAD_WH
database = UDHDEV
authenticator = ExternalBrowser
The documentation says to use warehousename and dbname but I think it's supposed to be warehouse and database?
Might be an issue with the doc / older versions of snowsql might use different property names...

Related

Snowflake Query returns Http status: Unprocessable Entity

I'm able to successfully connect to the Snowflake database through my .NET app, but I'm unable to run a SQL command due to the following error from the Snowflake:
Message: Http status: UnprocessableEntity
ResponseContent:
"code" : "391920",
"message" : "Unable to run the command. You must specify the warehouse to use by either setting the warehouse field in the body of the request or by setting the DEFAULT_NAMESPACE property for the current user.",
"sqlState" : "57P03",
"statementHandle" : "01a8
Here is my code I'm using.
public async Task<QueryResult> QuerySnowflake(string statement, string database, string schema)
{
var content = new
{
statement,
database,
schema
};
return await _httpClient.SnowflakePost<QueryResult>($"https://{_accountId}.snowflakecomputing.com/api/v2/statements", content, await GetHeaders(), _cancellationToken);
}
statement = SELECT * FROM SNOWFLAKE_SAMPLE_DATA.TPCH_SF1.CUSTOMER
database = SNOWFLAKE_SAMPLE_DATA
schema = TPCH_SF1
I have already tried the following:
ALTER USER my_username SET DEFAULT_NAMESPACE = SNOWFLAKE_SAMPLE_DATA.TPCH_SF1
GRANT SELECT ON ALL TABLES IN SCHEMA "TPCH_SF1" TO ROLE sysadmin
ALTER USER my_username SET DEFAULT_ROLE = sysadmin
All of these did not change the error response.
I don't think it needs a code change as it works with other Snowflake accounts (I'm using a new trial account). I believe I have my something wrong with my account (e.g. missing role, missing warehouse, missing permission, etc).
Any help would be very much appreciated.
The user does not have a default warehouse and none is specified in the connection request or a use command in the session. You can try sending this command before running your select:
use warehouse MY_WAREHOUSE;
You can also specify it in the connection, or specify a default for the user:
ALTER USER MY_USER SET DEFAULT_WAREHOUSE = MY_WAREHOUSE;

How to handle flyway when the db is down

This is my first time that i use flyway and i need help.
In lifetime of the microservice the postgres DB can shut down. I want to know how can flyway can get connection to the db again when it is up.
From what I know, you could use connectRetries while configuring flyway. For example:
flyway{
url = <Your url>
user = <Your user>
password = <Your password>
driver = <Mysql/Postgres Driver>
schemas = <Your schema>]
connectRetries = 3
locations = <Migration file location>
}

How to set the CONNECTION_OPTIONS = 'ApplicationIntent=ReadOnly' for elastic queries on Azure SQL?

I am accessing the other database using elastic queries. The data source was created like this:
CREATE EXTERNAL DATA SOURCE TheCompanyQueryDataSrc WITH (
TYPE = RDBMS,
--CONNECTION_OPTIONS = 'ApplicationIntent=ReadOnly',
CREDENTIAL = ElasticDBQueryCred,
LOCATION = 'thecompanysql.database.windows.net',
DATABASE_NAME = 'TheCompanyProd'
);
To reduce the database load, the read-only replica was created and should be used. As far as I understand it, I should add the CONNECTION_OPTIONS = 'ApplicationIntent=ReadOnly' (commented out in the above code). However, I get only the Incorrect syntax near 'CONNECTION_OPTIONS'
Both databases (the one that sets the connection + external tables, and the other to-be-read-only are at the same server (thecompanysql.database.windows.net). Both are set the compatibility lever SQL Server 2019 (150).
What else should I set to make it work?
The CREATE EXTERNAL DATA SOURCE Syntax doesn't support the option CONNECTION_OPTIONS = 'ApplicationIntent=ReadOnly'. We can't use that in the statements.
If you want achieve that readonly request, the way is that please use the user account which only has the readonly(db_reader) permission to login the external database.
For example:
CREATE MASTER KEY ENCRYPTION BY PASSWORD = '<password>' ;
CREATE DATABASE SCOPED CREDENTIAL SQL_Credential
WITH
IDENTITY = '<username>' -- readonly user account,
SECRET = '<password>' ;
CREATE EXTERNAL DATA SOURCE MyElasticDBQueryDataSrc
WITH
( TYPE = RDBMS ,
LOCATION = '<server_name>.database.windows.net' ,
DATABASE_NAME = 'Customers' ,
CREDENTIAL = SQL_Credential
) ;
Since the option is not supported, then we can't use it with elastic query. The only way to connect to the Azure SQL data with SSMS is like this:
HTH.

Oracle 12c Username forgot

a couple of days ago I installed oracle 12c. I ran it after a days or two but I completely lost my Username, I do remember my password but not username. I there any way by which I can see what username I set
Assuming that you can login as SYS, you can use:
select *
from dba_users
This will give all the users, including the one you defined; here you find something more.
There is new procedure for generating password since Oracle 11g. You can use
create or replace function get_hash_11g(p_password varchar2, p_salt varchar2) return varchar2 is
lv_pwd_raw RAW(128);
lv_enc_raw RAW(2048);
BEGIN
lv_pwd_raw := utl_raw.cast_to_raw(p_password) || hextoraw(p_salt);
lv_enc_raw := sys.dbms_crypto.hash(lv_pwd_raw, 3);
return lv_enc_raw;
end get_hash_11g;
/
Then run select
select w.name from sys.user$ w
where substr(w.spare4, 3, 40) = get_hash_11g(/*your password*/'&pass', substr(spare4, 43, 20));
/
Set up the following environment variables. They are not necessary for the process itself, but will help you navigate. In this case my domain is called "ClassicDomain". Remember to change the value to match your domain.
export MW_HOME=/u01/app/oracle/middleware
export DOMAIN_HOME=$MW_HOME/user_projects/domains/ClassicDomain
Shut down the WebLogic domain.
$ $DOMAIN_HOME/bin/stopWebLogic.sh
Rename the data folder.
$ mv $DOMAIN_HOME/servers/AdminServer/data $DOMAIN_HOME/servers/AdminServer/data-old
Reset the password using the following command. Remember to substitute the appropriate username and password.
$ cd $DOMAIN_HOME/security
$ java weblogic.security.utils.AdminAccount <username> <password> .
If you are able to invoke sqlplus then follow this:
sqlplus:/ as sysdba - this is the command needed to login as sys.
password: - don't give any password. Just hit enter
SQL> select username from dba_users; - this command will give list of users in the database.

PhpMyAdmin does not list a database I have access to

When I start phpMyAdmin, it does not list a database I have access too.
I know that the db exists and that I have access too, because its is the database used by one of my Joomla site.
I picked up the credential from my joomla configuration to the config.inc.php file.
Here is the file:
$cfg['Servers'][$i]['verbose'] = 'SQL9_MODULES';
$cfg['Servers'][$i]['host'] = 'sql9.modules';
$cfg['Servers'][$i]['port'] = '';
$cfg['Servers'][$i]['socket'] = '';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['extension'] = 'mysql';
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'xxxx';
$cfg['Servers'][$i]['password'] = 'yyy';
$cfg['DefaultLang'] = 'en';
$cfg['ServerDefault'] = 1;
$cfg['UploadDir'] = '';
$cfg['SaveDir'] = '';
I tried as mentionned in other post this command :
SELECT SCHEMA_NAME AS `Database` FROM INFORMATION_SCHEMA.SCHEMATA;
The results is empty.
I have also started the "Synchronize" function from my joomla database to my joomla database and pma found all the tables !!!!
The I tried to write some selects directly on the tables but I got a
#1046 - No database selected
Last remark, this is shared hosting, so I cannot connect as root to grand me some extra privileges !!
Thanks for your help
MySQL version : 5.1.66-0+squeeze1-log - (Debian)
phpMyAdmin version : 3.5.3
Update:
SHOW GRANTS FOR CURRENT_USER
gives
GRANT USAGE ON *.* TO 'xxxx'#'%' IDENTIFIED BY PASSWORD '*****************'
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE ON `xxxx`.* TO 'xxxx'#'%'
Any missing grants ?
Got answer from my ISP support. Needed to add the following line in the configuration:
$cfg['Servers'][$i]['only_db'] = 'my-database';
Now it works.

Resources