Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/swoole/ext-postgresql
🐘 Coroutine-based client for PostgreSQL
https://github.com/swoole/ext-postgresql
coroutine postgresql swoole
Last synced: 3 months ago
JSON representation
🐘 Coroutine-based client for PostgreSQL
- Host: GitHub
- URL: https://github.com/swoole/ext-postgresql
- Owner: swoole
- Archived: true
- Created: 2019-04-16T02:05:06.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-09-28T00:32:29.000Z (about 2 years ago)
- Last Synced: 2024-05-22T08:32:20.591Z (6 months ago)
- Topics: coroutine, postgresql, swoole
- Language: C++
- Homepage:
- Size: 117 KB
- Stars: 63
- Watchers: 11
- Forks: 20
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-swoole - swoole/ext-postgresql - A Swoole-based PostgreSQL client. (Client Packages)
README
# Swoole Coroutine Postgres Client
`ext-postgresql` is the Swoole Postgres Client library can be used with in the coroutine context without blocking.
### Pre-requirement
* `libpq` is required
* `swoole` version >= 4.4.0### Build & Installation
```bash
git clone [email protected]:swoole/ext-postgresql.git
phpize
./configure
make && make install
```Enable `swoole_postgresql` in php.ini by adding the following line:
```
extension=swoole_postgresql.so
```### How to use the Postgres Client
```php
connect("host=127.0.0.1 port=5432 dbname=test user=root password=password");
$db->prepare('fortunes', 'SELECT id, message FROM Fortune');
$res = $db->execute('fortunes', []);
$arr = $db->fetchAll($res);
var_dump($arr);$db->prepare('select_query', 'SELECT id, randomnumber FROM World WHERE id = $1');
$res = $db->execute('select_query', [123]);
$ret = $db->fetchAll($res);
var_dump($ret);
});
```You can find more examples in the `/examples` folder.