Dictionary in Python not printing updated key/value pair

I have a Python dictionary in my Selenium script in which one of the keys (“data”) is updated afterwards because it’s not a fixed value, so I get it with Selenium:

fields_personal = {
    "data": "", 
    "nome": "João da Silva",
    "documento": "CPF",
    "numero": "123.456.789-10",
    "telefone": "(01)23456-7890",
    "email": "teste@email.com"
}

for data, value in fields_personal.items():
    element = driver.find_element_by_id(data)
    element.send_keys(value)
    if data == "data":
        for item in element.find_elements_by_tag_name("option"):
            option = item.text.strip()
            elem = driver.find_element_by_xpath("//*(@id='data')/option(1)").click()
            fields_personal("data") = option
            break
    print("{}: {}".format(data, value))

No problem with that, it works fine. But when I try to print the dictionary with print("{}: {}".format(data, value)), or simply print(data, value) it prints “data” key with empty value, as if it hasn’t been updated:

data:  
nome: João da Silva
documento: CPF
numero: 123.456.789-10
telefone: (01)23456-7890
email: teste@email.com

The only way I can print the updated dictionary is calling pprint.pprint(fields_personal), since I want it structured line by line, but this outputs the result formatted with quotes and curly braces, which I don’t want:

{'data': '28/06/2021',
 'documento': 'CPF',
 'email': 'teste@email.com',
 'horario': '',
 'nome': 'João da Silva',
 'numero': '123.456.789-10',
 'telefone': '(01)23456-7890'}

So, how can I print it line by line, without quotes and curly braces and updated?

database – What are the means to which one can optimize key-value pairing in SQLITE?

Being holistically unfamiliar with the inner-workings and development history of SQL, I have to imagine that there are various strategies to optimize SQLITE in regards to key-value pairing. ( This is what I am primarily concerned with )

In researching the topic, I came across this white paper about SQLITE4 which is no longer being developed. SQLITE4 seemed to have a particular interest in optimizing itself for Key-Value Pairs.

https://www.sqlite.org/src4/doc/trunk/www/design.wiki

Some take-aways I took from it:

An instance of an sqlite4_env object defines how SQLite4 interacts with the rest of the system. An sqlite4_env object includes methods to:
access and control the underlying key/value storage engines,

The default built-in storage engine is a log-structured merge database. It is very fast, faster than LevelDB, supports nested transactions, and stores all content in a single disk file. Future versions of SQLite4 might also include a built-in B-Tree storage engine.

The PRIMARY KEY Is The Real Primary Key

SQLite3 allows one to declare any column or columns of a table to be the primary key. But internally, SQLite3 simply treats that PRIMARY KEY as a UNIQUE constraint. The actual key used for storage in SQLite is the rowid associated with each row.

SQLite4, on the other hand, actually uses the declared PRIMARY KEY of a table (or, more precisely, an encoding of the PRIMARY KEY value) as the key into the storage engine.

It has been stated that various lessons were learned from SQLITE4 and merged into SQLITE3, and I would like to know in addition what of the above, still applies?
Namely:

  1. Can one access and control the underlying key/value storage engines in SQLITE?
  2. Is there a B-Tree storage engine? Does it provide better write speeds?
  3. Is the Primary Key now, the “Real primary key”?
  4. If any of the previous questions ring true, what are the means these provide means to which one can optimize SQLITE for key-value pairs?

In addition, discussing the topic writ large, it has been suggested in private to me that

  1. Smaller files provide better write speeds.
  2. Paths to files are vastly faster than storing file data.
  3. Key Types will impact lookups.
  4. Reads can be accessed in multiple threads, however all writes should be delegated to one thread.

I would like to know if any of this is true.

Finally and most generally, are there any means not yet covered that one can utilize to optimize key value pairing? And more cynically; is this even a topic that warrants discussion, implying that any attempt to optimize is going to be superfluous?

Thanks.

mysql – How do I store key-value pairs in a column and query those values with comparisons

I am not sure if this is the best way to go about the problem I am facing.

I have a table of game items, where each game item has up to 13 types of upgradable items.

Each upgradeable item is denoted by a single character (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C).

So let’s say the item has 3 of upgradeable item “B”, and “7” of upgradeable item “C”, what’s the best way to store this information under a single column and be able to pull out what upgradeable items exist for that item, and select items that have greater than or equal to “x” number of a specific upgradeable item.

It looks easy to solve isn’t it? A foreign table for the upgradeable items and we plug the upgradeables there and boom, but no, sadly not, it needs to be in the same column, cannot add any more columns or tables.

mariadb – Should a meta_key or other key-value table columns use a HASH or BTREE index?

I’ve noticed that my WordPress database has BTREE indexes everywhere.

By my understanding, BTREE indexes allow more efficient < > and BETWEEN queries, but are otherwise less efficient than a HASH query for = and != queries.

This makes sense for some columns that might be filtered numerically (dates obviously, and IDs potentially, – though in practice ID > x doesn’t seem very likely in WordPress), but I can’t see any benefit for columns like meta_key which stores the text key of a key-value pair, or indeed the post_id column of a post_metadata table, which will almost without exception be JOINed to the posts table.

Would a HASH index be more performant? If so, is there any reason that my database is using BTREE indexes for these columns, or is this just a default? If not, what am I lacking in my understanding of indexes?

wp cli – How to add custom post meta key:value in woocommerce using wp-cli

I am Using WooCommerce cli to create product but having issue to add custom filed (key:value in postmeta table)

wp wc product create --name="Test Title" --description="Description goes here" --type=simple --sku=254896 --regular_price=50 --user=1 --meta_data="({"key1":"value1","key2":"value2"})"

Product is successfully saved but meta_data not saved against this product.

c# – Which key-value database should I use and why?

I have an application that scrapes webpages. Once a webpage is scraped, it has a unique identifier which is a string and it has the associated content which is also a string. I need to persist the webpage content, so that the next time I scrape the data for the same webpage I need to know whether the webpage has changed or not.

So either I might be storing the page identifier mapped with its checksum or simply its content. Anyhow, the basic need of storage is simple – a string to string map.

I think it is a use case for a key-value database. Since, my needs are very simple I don’t need a database full of fancy features. What could be a good open source key-value database that suits my simple needs?

Also, is it even necessary to use a database? I can fall back to a file storing the key-value. Will I lose performance if I use a database over a file?

python – KeyError: & # 39; id & # 39; after 100 key-value pairs have already been printed

I use Python to print the results of a view in CouchDB that contains key-value pairs of the result of a reduction function.
Everything works via the graphical interface of the browser, but with Python every 100 elements printed in the console gives me the following errors:

Traceback (most recent call last):

  File "D:UsersDesktopEsercitazioni NoSQLEsercitazione4MaxCasesView.py", line 31, in 
    for r in result:

  File "D:UsersDesktopEsercitazioni NoSQLEsercitazione4cloudantresult.py", line 400, in _iterator
    if last('id'):

KeyError: 'id'

This is the code:

result = db.get_view_result(ddoc, view_name, group = True)
for r in result:
    print(r('key'), "tt : ", r('value'))

When i do result = db.get_view_result(ddoc, view_name, group = True, skip = 100) it prints another 100 results and the 200th result gives me the same errors.

Is it possible to solve this problem or do I need to find a way to reload the view for every 100 items printed?

I'm using Python 3.8 and Cloudant libraries for CouchDB 3.1

Reconciliate and sync two records that have the same key-value in Google Sheets

I have a list of urls on a google sheet.

charlie.com |  apple   | 
alpha.com   |  orange  |
beta.com    |  banana  |

I have another list of data as a CSV (this could be imported into Google Sheets if this simplifies the workflow). These data are as follows:

charlie.com |  one
alpha.com   |  three 
beta.com    |  seven

(Note that the URLs are the same, but the other dates are different. The row order based on the URLs is also different.

I want to combine these two records so that I get the following:

charlie.com |  one    |  apple
alpha.com   |  three  |  orange
beta.com    |  seven  |  banana

(So ​​that all data is aligned correctly and the URLs are used as a key value.

How can I do that ?

Composer – Drush Migrate Upgrade "[debug] key_value table not found. The database may be empty. "

I'm trying to migrate a D7 site to D8 by following the steps outlined at drupal.org/docs/8/upgrade/upgrade-using-drush.

Once I can manage it and make sure I have all the PHP components, Drupal modules, etc., I need to update 4 sites that I suspect will be a very difficult one.

I have installed and used Composer to create a Drupal 8 site from my / home directory, with the intention of moving the files through the existing site. In addition, the Migrate upgrade appears to have to point to the D7 site via http.

If I run the following command to migrate the old (D7) site to this new D8 site, this will fail.

drush migrate-upgrade --legacy-db-url=mysql://user:password@server/db --legacy-root=http://example.com --configure only

with the following parameters for my specific environment

  • user = user with which the site connects to the database
  • password
  • server = localhost
  • db = database name
  • http://example.com = URL for the website

If it fails, it quotes (Debug) key_value table not found. The database may be empty. (0.1 sec., 9.59 MB) and when I check the MySQL database, I notice that there is no table name key value,

I could create the table if I know the requirements for the table (field names, field type, sizes, PK / FK, etc.). Or are there other ways to create this table.

Previously, I did everything manually. I thought since the update steps below (cloudways.com/blog/upgrade-drupal-7-to-drupal-8/) included the whole process of creating a D8 site and migrating the data to me that I have Composer and / or should use Drush. It's the first time I've let Composer and Drush work for me.

Any help would be appreciated.

Thanks.


I will get the next issue if I run the whole thing drush migrate upgrade Command:

Drush Launcher Version: 0.6.0
ROOT: / home / akwashnak / ctdollarsandsesne
DRUSH VERSION: 9
DRUPAL ROOT: / home / akwashnak / ctdollarsandsesne
Composer root: / home / akwashnak / ctdollarsandsesne
PROVIDER ROOT: / home / akwashnak / ctdollarsandsesne / vendor
(Preflight) configuration paths: /home/akwashnak/ctdollarsandsesne/vendor/drush/drush/drush.yml
(Preflight) alias paths: /home/akwashnak/ctdollarsandsesne/drush/sites, /home/akwashnak/drush/sites
(Preflight) command file search paths: / home / akwashnak / ctdollarsandsesne / vendor / drush / drush / src
(Debug) Bootstrap on to find Migrate upgrade (0.08 sec, 8.02 MB)
(Debug) Try to boot as far as possible (0.08 sec., 8.02 MB)
(Debug) Drush bootstrap phase: bootstrapDrupalRoot () (0.08 sec., 8.02 MB)
(Debug) working directory in / home / akwashnak / ctdollarsandsesne change (0.08 sec., 8.02 MB)
(Debug) Initialized Drupal 8.7.9 root at / home / akwashnak / ctdollarsandsesne (0.08 sec, 8.15 MB)
(Debug) Drush bootstrap phase: bootstrapDrupalSite () (0.09 sec., 8.5 MB)
(Debug) Initialized Drupal Site Standard at Sites / Standard (0.09 sec., 8.67 MB)
(Debug) Drush bootstrap phase: bootstrapDrupalConfiguration () (0.09 sec., 8.67 MB)
(Debug) Add Service Modifier (0.1 sec., 9.17 MB)
(Debug) key_value table not found. The database may be empty. (0.1 sec., 9.59 MB)
(Debug) bootstrap phase bootstrapDrupalDatabase () could not be validated. Continued with bootstrapDrupalConfiguration () (0.1 sec., 9.59 MB)
(Debug) Finish with Bootstrap Max in Application :: find (): again trying to find the upgrade for the migration. (0.1 sec., 9.59 MB)

In Application.php line 239:

(Symfony Component Console Exception CommandNotFoundException)
Command migrate-upgrade was not found. Drush could not query the database. As a result, many commands are not available. Run your command with -de again
Error displaying relevant log messages.

Exception tracking:
at /home/akwashnak/ctdollarsandsesne/vendor/drush/drush/src/Application.php:239
Drush Application-> bootstrapAndFind () at /home/akwashnak/ctdollarsandsesne/vendor/drush/drush/src/Application.php:192
Drush Application-> find () at /home/akwashnak/ctdollarsandsesne/vendor/symfony/console/Application.php:236
Symfony Component Console Application-> doRun () at /home/akwashnak/ctdollarsandsesne/vendor/symfony/console/Application.php:148
Symfony Component Console Application-> run () at /home/akwashnak/ctdollarsandsesne/vendor/drush/drush/src/Runtime/Runtime.php:118
Drush Runtime Runtime-> doRun () at /home/akwashnak/ctdollarsandsesne/vendor/drush/drush/src/Runtime/Runtime.php:49
Drush Runtime Runtime-> run () at /home/akwashnak/ctdollarsandsesne/vendor/drush/drush/drush.php:72
require () at /home/akwashnak/ctdollarsandsesne/vendor/drush/drush/includes/preflight.inc:18
drush_main () at phar: ///usr/local/bin/drush/bin/drush.php: 141
require () at / usr / local / bin / drush: 10