psql – POSTGRESQL Query and insert based on results

In this case I’m trying to perform a SELECT based query followed by an insert of new records into the same table based on those results. For example a simple table:

Table "samples"

Fields: 
      id   unique
      name 
      locations
      randoma
      randomb
      randomc

To be clear my objective from the selection is to create a new sample with a given name and id for each location, but the rest of the fields can be left to default. This is the selection portion:

SELECT locations FROM samples WHERE name = 'example';

The command chain below works for a single record, but I need the query and creation to be iterative. Aforementioned attempt:

INSERT INTO samples (nextval('my_sequence'), 'newsample', (SELECT locations FROM samples WHERE name = 'example');

I’ve haven’t found a solution yet and would appreciate any admonishment on this PSQL simplicity.

I realize that this is a poor example in terms of database normalization, but it’s merely for effect.

Best regards and thanks in advance.

python – How to do cURL query instead of webscraping?

(please dont downvote, comment where I should ask this)

I am trying to learn / understand how to do cURL query using python.

The website I am trying to get infos from is https://sale.kaddex.com/stats

What I am currently doing is to scrap the table from the website, but I want to be able to request directly from its query.

My current code follows bellow.

import pandas as pd
from selenium import webdriver
import time
import matplotlib.pyplot as plt

driver = webdriver.Chrome()

url = 'https://sale.kaddex.com/stats'

driver.get(url)

time.sleep(3)

df = pd.read_html(driver.page_source)(0)

driver.close()
driver.quit()

df = df(1:)

df('Amount KDA') = df('Amount KDA').astype(float)
df('Sum_qtd') = df('Amount KDA').cumsum()
df('Price/KDA') = 10000000/df('Sum_qtd')

print(df)

An acquaintance of mine told me that the following query should be utilized to accomplish what I am trying to do, but I dont know where to start.

curl 'https://api.chainweb.com/chainweb/0.0/mainnet01/chain/0/pact/api/v1/local' 
  -H 'authority: api.chainweb.com' 
  -H 'sec-ch-ua: " Not;A Brand";v="99", "Google Chrome";v="91", "Chromium";v="91"' 
  -H 'sec-ch-ua-mobile: ?0' 
  -H 'user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.77 Safari/537.36' 
  -H 'content-type: application/json' 
  -H 'accept: */*' 
  -H 'origin: https://sale.kaddex.com' 
  -H 'sec-fetch-site: cross-site' 
  -H 'sec-fetch-mode: cors' 
  -H 'sec-fetch-dest: empty' 
  -H 'referer: https://sale.kaddex.com/' 
  -H 'accept-language: fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7' 
  --data-raw '{"hash":"vxUfyBj6Pz3iOK9iag-yooRdEyXKg3GaDsPQAU7z94k","sigs":(),"cmd":"{"networkId":null,"payload":{"exec":{"data":{},"code":"(kdx.priv-sale.read-all-reservations)"}},"signers":(),"meta":{"creationTime":1623428512,"ttl":600,"gasLimit":100000,"chainId":"0","gasPrice":1e-12,"sender":""},"nonce":"\"2021-06-11T16:22:01.886Z\""}"}' 
  --compressed

databases – How to simplify the query qualification?

Given the following DB and query :
enter image description here

enter image description here

Now if we need to simplify the query qualification, here is the answer from the book (Principle of distributed database systems, third edition) :

enter image description here

My question is in the highlighted bracket, I think this should be (p1 OR (p2 AND (Not p2))) instead of the one written because we have the following rule :

enter image description here

Is that right ?

sql – Query Condicional – Stack Overflow en español

tengo el siguiente problema.

Necesito asignar la fecha a un registro en donde tengo que elegir la fecha vigente del costo unitario.

Para aclarar el problema, por ejemplo tengo la siguiente situación:

Datos de ejemplo:

CREATE TABLE dbo.Movimiento(Cod varchar(3), Cantidad int, Fecha date);
CREATE TABLE dbo.Unitario(Cod varchar(3), Costo int, Fecha date);

INSERT INTO dbo.Movimiento 
VALUES  ('AAA',2,'20180125'),
        ('AAA',3,'20190901'),
        ('AAA',5,'20200401'),
        ('BBB',4,'20200527'),
        ('BBB',4,'20210527'),
        ('ccc',1,'20210501');


INSERT INTO dbo.Unitario 
VALUES  ('AAA',200,'20180125'),
        ('AAA',300,'20191231'),
        ('BBB',500,'20191231'),
        ('BBB',1000,'20201231'),
        ('ccc',1500,'20211231');

Query que obtiene el menor más cercano:

SELECT *
FROM dbo.Movimiento m
OUTER APPLY ( SELECT TOP 1 
                     fecha 
               FROM  dbo.Unitario u
               WHERE u.Cod = m.Cod 
               AND   u.Fecha <= m.Fecha 
               ORDER BY u.Fecha DESC) u 

Mi problema es que debo asignar el costo Unitario ( tabla Unitario) al código de tabla Movimiento, en donde la fecha del Movimiento debe ser menor o igual a la de la tabla de costo Unitario; sin embargo, puede existir el caso en que la fecha de costo unitario sea menor ( Por que es la vigente de ese año, como sucede en el caso del código C).

Este es el Resultado que debo obtener con el ejemplo planteado:

introducir la descripción de la imagen aquí

He estado buenas horas con el problema y aún no se me ocurre una solución. Les agradecería si me ayudan con un par de ideas.

Aquí tengo un enlace con lo que llevo: http://sqlfiddle.com/#!18/4d326/15

query performance – INSERTing into a tag_map in MySQL

I have a simple article and tag_map tables as

CREATE TABLE Articles
(
ArticleID int(11) unsigned NOT NULL AUTO_INCREMENT,
Title varchar(255),
PRIMARY KEY(ArticleID)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_general_ci

CREATE TABLE Tags
(
TagID int(11) unsigned NOT NULL AUTO_INCREMENT,
Tag varchar(255),
UNIQUE INDEX(Tag),
PRIMARY KEY(TagID)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_general_ci

CREATE TABLE TagMap
(
ArticleID int(11) unsigned NOT NULL,
TagID int(11) unsigned NOT NULL,
INDEX(TagID),
PRIMARY KEY(ArticleID,TagID)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_general_ci

I add tags via PHP

$result=$mysqli->query("SELECT TagID FROM Tags WHERE Tag='$tag'");
if($result->num_rows==1){
    $row=$result->fetch_assoc();
    $tag_id=$row('TagID');
}
else{
$mysqli->query("INSERT INTO Tags (Tag) VALUES ('$tag')");
$tag_id=$mysqli->insert_id;
}

$mysqli->query("INSERT INTO Tags (ArticleID,TagID) VALUES ($article_id,$tag_id)");

I wonder if there is a faster way to do this in one query within MySQL.

Here, I need 2 or 3 queries for adding each tag.

Additionally, I hope to find a way for batch INSERT (possibly via LOAD DATA LOCAL INFILE) when we have a list of tags as

ArticleID,Tag
1,tag2
2,tag11
4,tag3

sql server – Page level Deadlock on same delete query

sql server – Page level Deadlock on same delete query – Database Administrators Stack Exchange

Duplicate Query rest end points in microservices – CQRS

I am a newbie to microservice. Currently I’m learning microservices by creating 2 microservices with CQRS pattern, with NO event sourcing, but each service has separate DB. Each service has separate end points for Command and Query. There is no separate Read store and write store.
The services communicate with each other via restend points.

From UI point of view, a Query restend point typically expects Paginated data. However when one service queries other service, the expected data need not be paginated. It just needs the data to continue the business logic (say to verify if an entity exists).

Is it ok to have two rest end points which pretty much does the same thing but the output format is different and purpose is different.

PS: This question is specific to the above implementation only (CQRS with no event sourcing and communication via restend points).

html5 – Visualización de imagen en media query

Mi inconveniente es relacionado a un carrusel de imágenes específicamente a la visualización de las mismas ya que no logro ajustarlas al contenedor, se que con la propiedad object-fit:contain se lo puede hacer y ya lo he tratado pero sigo viendo solo un porcentaje de cada imagen.

Las imágenes tienen de altura: 1280 y ancho: 333. A parte estoy utilizando “MultiSlider” para esto del carrusel.

En el html tengo lo siguiente:

<div class="principal-slider">
            <div id="slider">
               <div class="MS-content">
                  <div class="item">
                     <img class="img-slider" src="../RSC/slider/1.jpeg" alt="" id="imgSLIDE1">
                  </div>
                  <div class="item">
                     <img class="img-slider" src="../RSC/slider/1.jpeg" alt="" id="imgSLIDE2">
                  </div>
                  <div class="item">
                     <img class="img-slider" src="../RSC/slider/1.jpeg" alt="" id="imgSLIDE3">
                  </div>
                  <div class="item">
                     <img class="img-slider" src="../RSC/slider/1.jpeg" alt="" id="imgSLIDE4">
                  </div>
                  <div class="item">
                     <img class="img-slider" src="../RSC/slider/1.jpeg" alt="" id="imgSLIDE5">
                  </div>
               </div>
               <div class="MS-controls">
                  <button class="MS-left" id="btnIzqSlide">
                     <i class="icon-left-dir"></i>
                  </button>
                  <button class="MS-right" id="btnDerSlide">
                     <i class="icon-right-dir"></i>
                  </button>
               </div>
            </div>
         </div>

En el css tengo las siguientes líneas adentro de un @media screen and (max-width:360px):

 /*---SLIDER---*/
   .principal-slider{
      width:100%;
      margin: auto;
   }
   #slider {
      position: relative;
      width: 100%;
      margin: 0 auto 45px 0;
      box-shadow: 0 0 0 0 #1E2126,
                  0 5px 25px;
   }
   #slider .MS-content {
      white-space: nowrap;
      overflow: hidden;
      width: 100%;
      
   }
   #slider .MS-content .item {
      display: inline-block;
      width: 100%;
      object-fit: contain;
      position: relative;
      vertical-align: top;
      overflow: hidden;
      height: auto;
      white-space: normal;
   }
   #slider .MS-controls button {
      position: absolute;
      top: 35px;
   }
   #slider .MS-controls .MS-left {
      left: 10px;
   }
   #slider .MS-controls .MS-right {
      right: 10px;
   }

Según el editor no hay problemas de lógica en el html ni en el css pero yo creo que alguna cosa me falla en el css.

Les dejo una foto de como se encuentra el resultado:

visualización en disp. móvil

Por lo pronto seguiré investigando.

seo – Why did my website suddenly decrease the number of external links in the browser? I use Google tools to query and see that this is my site?

seo – Why did my website suddenly decrease the number of external links in the browser? I use Google tools to query and see that this is my site? – Webmasters Stack Exchange

wp query – Multisite – how to stop rewriting and redirecting to wrong locations?

How can I stop my wordpress multisite from rewriting my URLs from:

/news/?paged=20

to

/news/page/20/

I have this set up in my functions.php

function add_query_vars_filter( $vars ) {
  $vars() = 'paged'; // variable for pagination.
  $vars() = 'p'; // variable page for pagination.
  return $vars;
}
add_filter('query_vars', 'add_query_vars_filter');

And I have no ideas why WordPress keeps rewriting my URLs.

Sometimes, it just redirects to:

/en/hello-world/

That is completely wrong!

Any ideas?

DreamProxies - Cheapest USA Elite Private Proxies 100 Private Proxies 200 Private Proxies 400 Private Proxies 1000 Private Proxies 2000 Private Proxies ExtraProxies.com - Buy Cheap Private Proxies Buy 50 Private Proxies Buy 100 Private Proxies Buy 200 Private Proxies Buy 500 Private Proxies Buy 1000 Private Proxies Buy 2000 Private Proxies ProxiesLive Proxies-free.com New Proxy Lists Every Day Proxies123