diff --git a/pathauto.api.php b/pathauto.api.php
index e4d7594..fc9272f 100644
--- a/pathauto.api.php
+++ b/pathauto.api.php
@@ -84,7 +84,7 @@ function hook_path_alias_types_alter(array &$definitions) {
 function hook_pathauto_is_alias_reserved($alias, $source, $langcode) {
   // Check our module's list of paths and return TRUE if $alias matches any of
   // them.
-  return (bool) db_query("SELECT 1 FROM {mytable} WHERE path = :path", array(':path' => $alias))->fetchField();
+  return (bool) \Drupal::database()->query("SELECT 1 FROM {mytable} WHERE path = :path", [':path' => $alias])->fetchField();
 }
 
 /**
diff --git a/src/Plugin/pathauto/AliasType/EntityAliasTypeBase.php b/src/Plugin/pathauto/AliasType/EntityAliasTypeBase.php
index 98ed1e7..0cf2219 100644
--- a/src/Plugin/pathauto/AliasType/EntityAliasTypeBase.php
+++ b/src/Plugin/pathauto/AliasType/EntityAliasTypeBase.php
@@ -118,7 +118,7 @@ class EntityAliasTypeBase extends ContextAwarePluginBase implements AliasTypeInt
     $entity_type = $this->entityTypeManager->getDefinition($this->getEntityTypeId());
     $id_key = $entity_type->getKey('id');
 
-    $query = db_select($entity_type->get('base_table'), 'base_table');
+    $query = \Drupal::database()->select($entity_type->get('base_table'), 'base_table');
     $query->leftJoin('url_alias', 'ua', "CONCAT('" . $this->getSourcePrefix() . "' , base_table.$id_key) = ua.source");
     $query->addField('base_table', $id_key, 'id');
 
diff --git a/src/Tests/PathautoMassDeleteTest.php b/src/Tests/PathautoMassDeleteTest.php
index e528ba6..a245159 100644
--- a/src/Tests/PathautoMassDeleteTest.php
+++ b/src/Tests/PathautoMassDeleteTest.php
@@ -82,7 +82,7 @@ class PathautoMassDeleteTest extends WebTestBase {
     $this->assertUrl('admin/config/search/path/delete_bulk');
 
     // Make sure that all of them are actually deleted.
-    $aliases = db_select('url_alias', 'ua')->fields('ua', array())->execute()->fetchAll();
+    $aliases = \Drupal::database()->select('url_alias', 'ua')->fields('ua', array())->execute()->fetchAll();
     $this->assertEqual($aliases, array(), "All the aliases have been deleted.");
 
     // 2. Test deleting only specific (entity type) aliases.
diff --git a/src/Tests/PathautoTestHelperTrait.php b/src/Tests/PathautoTestHelperTrait.php
index b8b8075..2568638 100644
--- a/src/Tests/PathautoTestHelperTrait.php
+++ b/src/Tests/PathautoTestHelperTrait.php
@@ -134,7 +134,7 @@ trait PathautoTestHelperTrait {
   }
 
   public function deleteAllAliases() {
-    db_delete('url_alias')->execute();
+    \Drupal::database()->delete('url_alias')->execute();
     \Drupal::service('path.alias_manager')->cacheClear();
   }
 
