# Multiple Databases Simultaneously

**URL:** <https://forums.swift.org/t/multiple-databases-simultaneously/50386>\
**Category:** GRDB\
**Created:** [July 12, 2021, 4:23pm UTC](https://forums.swift.org/t/multiple-databases-simultaneously/50386 "2021-07-12T16:23:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Paul-TM](https://avatars.discourse-cdn.com/v4/letter/p/8dc957/32.png) [@Paul-TM](https://forums.swift.org/u/Paul-TM)\
**Post date:** [July 12, 2021, 4:23pm UTC](https://forums.swift.org/t/multiple-databases-simultaneously/50386/1 "2021-07-12T16:23:44Z")

</div>

Hi Gwendal,  
I'm looking at a problem that requires connection to 2 SQLite databases at the same time (RW on both). Its iOS 14 and latest GRDB if relevant.

I tried to work with this by implementing two separate DB Queues, one for each database. It seemed to work as far as opening the database but writing to the second seems like an issue.

Is this model supported by GRDB (in which case I can happily look for the bug in my own code) or if it's not I can then look at an alternative design (no idea what that is right now !)

Thanks

Paul

---

<div class="post-metadata">

**Author:** ![gwendal.roue](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/gwendal.roue/32/13992_2.png) [@gwendal.roue](https://forums.swift.org/u/gwendal.roue)\
**Post date:** [July 12, 2021, 4:55pm UTC](https://forums.swift.org/t/multiple-databases-simultaneously/50386/2 "2021-07-12T16:55:16Z")

</div>

Hello @Paul-TM

Nothing prevents you from accessing two databases at the same time:

```swift
try dbQueue1.write { db1 in
  try dbQueue2.write { db2 in
    ...
  }
}

```

---

<div class="post-metadata">

**Author:** ![Paul-TM](https://avatars.discourse-cdn.com/v4/letter/p/8dc957/32.png) [@Paul-TM](https://forums.swift.org/u/Paul-TM)\
**Post date:** [July 13, 2021, 7:56am UTC](https://forums.swift.org/t/multiple-databases-simultaneously/50386/3 "2021-07-13T07:56:27Z")

</div>

Thanks for the response Gwendal. Must be muddy code as I feared 😃
