Categories
Development

Add a composite constraint and view it, MySQL/MariaDB

Add

Adding constraint NetAppToken composing of 3 columns: network, application, token.
Note: you supposed to have chosen a right db:
use <database_name>;

ALTER TABLE crypto   
    ADD CONSTRAINT NetAppToken UNIQUE (network, application, token);

View

SELECT 
   table_schema,  
   table_name,    
   constraint_name
FROM information_schema.table_constraints
WHERE table_name = 'crypto';

Result

+--------------+------------+-----------------+
| table_schema | table_name | constraint_name |
+--------------+------------+-----------------+
| admin_crypto | crypto     | PRIMARY         |
| admin_crypto | crypto     | NetAppToken     |
+--------------+------------+-----------------+
2 rows in set (0.06 sec)
Categories
Development

CURL request into Curl PHP code

Recently I needed to transform the CURL request into the PHP Curl code, binary data and compressed option having been involved. See the query itself:

curl 'https://terraswap-graph.terra.dev/graphql' 
-H 'Accept-Encoding: gzip, deflate, br' 
-H 'Content-Type: application/json' 
-H 'Accept: application/json' 
-H 'Connection: keep-alive' 
-H 'DNT: 1' 
-H 'Origin: https://terraswap-graph.terra.dev' 
--data-binary '{"query":"{\n  pairs {\n    pairAddress\n    latestLiquidityUST\n    token0 {\n      tokenAddress\n      symbol\n    }\n    token1 {\n      tokenAddress\n      symbol\n    }\n    commissionAPR\n    volume24h {\n      volumeUST\n    }\n  }\n}\n"}' 
--compressed