pg-libphonenumber/README.md

57 lines
1.3 KiB
Markdown
Raw Normal View History

2017-12-09 23:42:29 +00:00
# `pg_libphonenumber`
2017-02-18 17:46:11 +00:00
A (partially implemented!) PostgreSQL extension that provides access to
[Google's `libphonenumber`](https://github.com/googlei18n/libphonenumber)
2015-07-24 21:27:51 +00:00
## Project status
2017-07-06 16:23:32 +00:00
This extension is in an **alpha** state. It's not complete or tested enough for
critical production deployments, but with a little help, we should be able to
get it there.
## Synopsis
2017-07-06 16:23:32 +00:00
```sql
CREATE EXTENSION pg_libphonenumber;
SELECT parse_phone_number('03 7010 1234', 'AU');
SELECT parse_phone_number('2819010011', 'US');
2017-02-18 17:46:11 +00:00
2017-07-06 16:23:32 +00:00
CREATE TABLE foo ( ph phone_number );
2017-02-18 17:46:11 +00:00
2017-07-06 16:23:32 +00:00
-- DO NOT RELY ON THIS
-- may not always this work way with implicit cast.
SELECT '2819010011'::phone_number; -- assumes US
```
## Installation
### Debian/Ubuntu
2017-07-06 16:23:32 +00:00
First you'll need to install `libphonenumber-dev` and the corresponding
`postgresql-server-dev` package.
2017-07-06 16:23:32 +00:00
```shell-script
2017-07-06 17:07:28 +00:00
sudo apt-get update && sudo apt-get install \
build-essential \
postgresql-server-dev-9.6 \
libphonenumber-dev
2017-07-06 16:23:32 +00:00
```
2017-07-06 16:23:32 +00:00
Then clone this repository and build.
2017-07-06 16:23:32 +00:00
```shell-script
git clone https://github.com/blm768/pg-libphonenumber
cd pg-libphonenumber
make
sudo make install
```
2017-07-06 17:07:28 +00:00
## Running tests
For convenience, we provide a Docker image that sets up a test environment.
```shell-script
make docker-image
2017-12-09 23:42:29 +00:00
docker run -it pg_libphonenumber
2017-07-06 17:07:28 +00:00
```