Questions tagged [database]
Drupal provides a standard, vendor-agnostic abstraction layer for accessing database servers.
3,129
questions
-2
votes
0
answers
29
views
Database connection issue SQLSTATE[HY000] [2002] Connection refused - Pantheon [closed]
The issue I have is a db connection issue
The website encountered an unexpected error. Try again later.
Drupal\Core\Database\DatabaseConnectionRefusedException: SQLSTATE[HY000] [2002] Connection ...
2
votes
1
answer
188
views
How do I alter a table by using AFTER in hook update?
I am trying to alter an existing table to add new column. I am able to add new column successfully. But the created new column is added at the end of the table. I want the column to be added after a ...
0
votes
1
answer
31
views
Problem Removing Seven Theme "You must add the following contributed theme and reload this page."
I have removed the Seven theme from my Drupal 10 installation as I no longer use it.
Unistalled from Appearance UI
composer remove
Deleted all references from key_value table. SELECT * FROM ...
-2
votes
0
answers
15
views
deleteTranslationSource - MYSQL and Website down - Lock wait issue [duplicate]
Whenever Drupal users create or modify from the Drupal Interface and rebuild the cache, then immediately the Drupal website goes down. when we check the logs there is an error as below,
This error we ...
-4
votes
2
answers
72
views
CPU high usage and database down after performing delete token [closed]
Whenever Drupal users create or modify from the Drupal Interface and rebuild the cache, then immediately the Drupal website goes down. when we check the logs there is an error as below,
This error we ...
0
votes
2
answers
58
views
"drush site:install ... " denied access to database and module not found exception
I am using the below drush command to install a Drupal site, but this results in an access denial to database and failure to find an installed module existing in the right directory and already ...
0
votes
1
answer
24
views
Need Drupal equivalent mysql Update query
I have plain mysql update query which needs to be append with existing values.
Example: appid coloumn containing 'abc' and now I want to append with some new values. Example: 'abc,xyz'
The below mysql ...
1
vote
0
answers
47
views
MySQL log files filling disk
I do not know much about Drupal. I have a Drupal 10 installation using MySQL 8.0.37 on Ubuntu 22.04. The Drupal site is the only thing running on this server.
MySQL is filling the /var/lib/mysql/ ...
0
votes
1
answer
44
views
Best practice design route for an estimates table
I need to allow users to store monthly estimates so that they can be later retrieved in our management information system.
It would look something like this but with the next 12 months. The first ...
1
vote
0
answers
56
views
Huge mysql binary logs
Since the last Drupal 10.3 update, we have had the problem that the storage space fills up rapidly (1-2 GB per hour).
After a more detailed analysis, it became apparent that the /var/lib/mysql folder ...
2
votes
1
answer
46
views
Force data initialization on custom module installation
I have a module that needs to initialize its database tables with data acquired from the existing site. What hook should I use?
hook_install() is obviously not suited for longer operations and doesn't ...
0
votes
1
answer
104
views
Column not found: 1054 Unknown column after creating new field
Background
I attempted to add a new field "Audience" which is an entity reference field referencing an "Audience" taxonomy. After creating this, I attempted to edit it to allow the ...
0
votes
0
answers
32
views
How can I switch between databases in a multisite environment using the entity API?
I'm working in a multisite environment and need to switch between databases based on certain conditions. I successfully switched the active database connection using Database::setActiveConnection() in ...
-1
votes
1
answer
25
views
Error with Chado module installation
As part of college course work, I am required to make a genomic database with a local website with basic features. I have installed Drupal 10.2.3 with PostgreSQL 14.11, PHP 8.3.4 and Tripal 4.0.0-...
3
votes
1
answer
118
views
How to delete duplicate path aliases?
Duplicate path aliases are seen as rows in the path_alias table with identical path and alias columns.
Due to old bugs in pathauto and other reasons, like buggy custom code, it is possible to have ...
0
votes
0
answers
183
views
How to speed up View render time in Drupal Views?
I have pretty big View which returns hundreds of rows and I am struggling with View render time. Stats are as follow:
Query build time: 44.69 ms
Query execution time: 111.52 ms
View render time: 6978....
-2
votes
1
answer
55
views
Why is the db connection to migrate silently failing?
I'm using D10, drush 12, ddev.
In settings.local.php I have:
$databases['migrate']['default'] = array (
'database' => 'd7',
'username' => 'db',
'password' => 'db',
'host' =>...
-3
votes
2
answers
43
views
database query's columnCount() and getColumnMeta() missing from core
In Drupal 9 I could do:
$result = \Drupal::database()->query($query, $args);
then call
$result->columnCount()
also
$recs->getColumnMeta($c)
In Drupal 10 these functions: columnCount() and ...
0
votes
1
answer
22
views
Is the DRUPAL_DATABASE_HOST value stored somewhere in the database?
I want to see what the value is for the database host, the value that you enter when installing for the first time.
Is there a way to see and edit this value after installation? Is it stored in a ...
0
votes
0
answers
84
views
How to establish a database connection to Microsoft SQL server that has more than one server instance?
For an MSSQL database at the IP 192.168.55.55 and a server name of MYDB2, what should my database settings be in the settings.php file? (Please note, the machine has more than one database server, so ...
0
votes
2
answers
223
views
Update database issue
In 2 of my 3 Drupal websites, drush updb crashes with the following error after upgrading from Drupal 9.5.11 to Drupal 10.2.2.
In BatchStorage.php line 143:
[Exception]
Serialization of 'Closure' ...
0
votes
1
answer
44
views
REGEX_REPLACE error when running DB query from update hook
This MySQL statement runs fine on MySQL 8.0.33-0ubuntu0.20.04.2:
mysql> UPDATE node__body SET body_value = REGEXP_REPLACE(body_value, "<img.*base64.*>", "");
Query OK, 0 ...
0
votes
1
answer
94
views
How to let users write private letters to me about a node?
I want to let users the ability to write personal letters to me based on nodes they read while letters are stored in the Drupal database itself (no emails involved) and will include these fields:
...
0
votes
0
answers
37
views
Kernel and functional testing with an MSSQL database
I am new to testing custom modules. My custom modules create and update custom nodes. From my reading, I need to use Kernel or Functional tests to test these operations. My Drupal 9 installation is ...
0
votes
2
answers
103
views
How can I get the record of the last insert?
Is there a method to be called that will get the ID of the record just inserted?
In my module the first thing done is the insert of some data into a table.
After that I have other things to do in the ...
1
vote
0
answers
131
views
PDOStatement::execute(): SSL: Broken pipe [closed]
I have a Drupal 9.5.11 site running well on a single EC2 instance and a remote MySQL server (RDS). I am trying to replicate a very similar scenario with a single EC2 instance but I am using AWS ...
0
votes
0
answers
77
views
Unable to add Menu Items due to IntegrityConstraintViolationException
Background
I recently encountered an error when I try to create a new menu item:
Drupal\Core\Entity\EntityStorageException: SQLSTATE[HY000]: General error: 1364 Field 'parent' doesn't have a default ...
0
votes
1
answer
146
views
How to join the node table with the url_alias table in a dynamic query?
Joining the node table to the url_alias table requires CONCAT. Here is an example of how this can be done:
$results = $db->query("
SELECT
n.nid, n.title,
a.source, a.alias
FROM ...
0
votes
1
answer
84
views
How do I sort view results by query order?
In my twig I use {{ drupal_view('slider', 'block_1', '74,84,82' ) }}, how can I make sure the output of this view has the slides in that specific order?
Currently on D9. I've looked around but can't ...
3
votes
1
answer
175
views
Drupal::entityQuery add CASE to have NULL values displayed last
I want to sort some entities in ascending expiration date, but I want those without expiration date to be at the end. Is there a way to add a CASE expression like this to the Drupal::entityQuery?
$...
1
vote
2
answers
114
views
Finding all nodes not referenced by a menu
I see this question was asked for Drupal 7, but the menu_link table doesn't exist in Drupal 9.
Is there a SQL query for listing all nodes that are not assigned to a menu?
0
votes
1
answer
824
views
Multiple primary key defined When importing DB to Dev
I'm trying to update my D9 dev site database using my production database, but it keeps erroring out when it reaches to ALTER table section in the database.
This is the
ERROR 1068 (42000) at line ...
0
votes
0
answers
87
views
How do I switch from PostgreSQL to MySQL
I set up a website using Drupal 10 and PostgreSQL but due to a communication delay, I just found out from the server team that the database on the staging/live servers is MySQL and not PostgreSQL. I ...
2
votes
1
answer
153
views
Paragraph Entity Query returns too many results
I'm trying to find a paragraph that have a certain taxonomy term value and on a matching parent node. I tried the code below, but it always returns over 30 values, when really only one paragraph ...
-1
votes
1
answer
110
views
Using common database for multiple developers in local environment gets slow
When use the common database to develop in local environment for multiple developers in one Drupal 9 project is getting too slow. This issue occurs on Drupal sites only, others (Wordpress, Laravel, ...
1
vote
1
answer
534
views
Can I use entityQuery() in a Drupal 10 site to query entities from a Drupal 7 database?
Can I use entityQuery() to query entities in a Drupal 7 table?
I know it's possible to change the active database and then use a dynamic query to access the database, but can I do that also with ...
0
votes
1
answer
133
views
Condition that deletes rows older than 30 days
How can I query a condition that deletes the rows with column Date older than the last 30 days in DBTNG format?
I have tried this, but it's wrong.
$connection = \Drupal::database();
$connection->...
0
votes
1
answer
38
views
DBTNG sentence that sums a column from all rows of a specific user and dpm the total
This is my table test_sum_expression with columns:
uid (int) Stores the UID of the user.
points (int) Stores a number.
I have this SQL sentence which SUMS all points from user with uid 1.
SELECT uid, ...
0
votes
1
answer
268
views
Database addExpression SUM: Call to a member function execute() on string
I need to get the sum of all points values of the user with uid 1 from the test_sum_expression table. But when I try to execute I get this message Error: Call to a member function execute() on string....
5
votes
0
answers
58
views
Prioritise condition in QueryInterface
I have an overview with a search field. The query should search on both the title and description, but I would want to show my results that have the search parameter in the title first in the list.
I ...
-2
votes
3
answers
174
views
Get the HTML content from the database [closed]
I have a copy of a Drupal 9 database from which I need to download all the pages.
I loaded the database in MySQL Workbench CE and connected to it via Python. There are many tables, but no views or ...
0
votes
1
answer
482
views
The specified database connection is not defined: default for Drupal drush
I have the following configurations for my Drupal site:
sites/mysite/settings.local.php
$databases['default']['default'] = array(
'database' => 'mydb',
'username' => 'root',
'password' =&...
1
vote
1
answer
180
views
Schema insert row only if primary key doesn't exist
I'm doing an exercise where I have a table called visit_counter with fields uid (primary key that stores the user id) and user_visit_count (sum of user's page visits). The purpose of the table is to ...
0
votes
1
answer
54
views
How to delete a no longer used custom bin table?
I'm testing the cacheAPI with a custom bin. Everything is working. On the other hand, while testing, I created a custom bin with a name that does not suit me.
cache.lorem_bin:
class: Drupal\Core\...
1
vote
1
answer
96
views
While upgrading from D6, update.php appears to expect the Drupal 7 version of the database array and it throws errors
Leaving settings.php in place (but writeable), per instructions 13 + 14 of major upgrade section of https://api.drupal.org/api/drupal/UPGRADE.txt/7.x , with the new D7 codebase but the old D6 DB, i ...
1
vote
2
answers
162
views
Custom views filter plugin: filter over two fields of a custom entity where one of the fields is a multi value field in a seperate table
I have a custom entity with two basefields of type "list_string": "role" and "additional_role". I need this as "role" is used for sorting the entities by a very ...
-2
votes
1
answer
163
views
How can i subscribe/unsubscribe to a simplenews newsletter programmatically?
I have the following code to set subscriptions to a simplenews newsletter on or off:
$user_load = User::load($userID_current);
$newsletter_subscriptions = [
'newsletter1' => 'on',
...
1
vote
0
answers
51
views
How to add groupBy option WITH ROLLUP
With Drupal 9.5.3, a group by like this:
$query->groupBy("myfieldname WITH ROLLUP");
will result in
(...) Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42S22]: Column not ...
1
vote
0
answers
34
views
How can I find all the nodes that use a hierarchical vocabulary taxonomy term and reference a child term but not its parent term
I am using Drupal 7.
I have a content type "Public Resource" that uses a hierarchical vocabulary called "Resource Topics" that has up to 3 levels (parent->child->child of ...
4
votes
0
answers
182
views
How can I dynamically switch between two databases for ALL queries?
I need to copy some entities from one Drupal 9 database to different Drupal 9 database. I have searched and looked high and low, but none of the examples I have found work anywhere. I found no help on ...