Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jackc/pgmock
https://github.com/jackc/pgmock
Last synced: 5 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/jackc/pgmock
- Owner: jackc
- License: mit
- Created: 2017-01-25T03:15:22.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2023-12-08T07:04:37.000Z (11 months ago)
- Last Synced: 2024-10-29T17:57:13.420Z (8 days ago)
- Language: Go
- Size: 49.8 KB
- Stars: 119
- Watchers: 3
- Forks: 15
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pgmock
pgmock provides the ability to mock a PostgreSQL server.
See pgmock_test.go for example usage.
## pgmockproxy
pgmockproxy is a PostgreSQL proxy that logs the messages back and forth between the PostgreSQL client and server. This
can aid in building a mocking script by running commands against a real server to observe the results. It can also be
used to debug applications that speak the PostgreSQL wire protocol without needing to use a tool like Wireshark.Example usage:
```
$ pgmockproxy -remote "/private/tmp/.s.PGSQL.5432"
F {"Type":"StartupMessage","ProtocolVersion":196608,"Parameters":{"application_name":"psql","client_encoding":"UTF8","database":"jack","user":"jack"}}
B {"Type":0,"Salt":[0,0,0,0],"SASLAuthMechanisms":null,"SASLData":null}
B {"Type":"ParameterStatus","Name":"application_name","Value":"psql"}
B {"Type":"ParameterStatus","Name":"client_encoding","Value":"UTF8"}
B {"Type":"ParameterStatus","Name":"DateStyle","Value":"ISO, MDY"}
B {"Type":"ParameterStatus","Name":"integer_datetimes","Value":"on"}
B {"Type":"ParameterStatus","Name":"IntervalStyle","Value":"postgres"}
B {"Type":"ParameterStatus","Name":"is_superuser","Value":"on"}
B {"Type":"ParameterStatus","Name":"server_encoding","Value":"UTF8"}
B {"Type":"ParameterStatus","Name":"server_version","Value":"11.5"}
B {"Type":"ParameterStatus","Name":"session_authorization","Value":"jack"}
B {"Type":"ParameterStatus","Name":"standard_conforming_strings","Value":"on"}
B {"Type":"ParameterStatus","Name":"TimeZone","Value":"US/Central"}
B {"Type":"BackendKeyData","ProcessID":31007,"SecretKey":1013083042}
B {"Type":"ReadyForQuery","TxStatus":"I"}
F {"Type":"Query","String":"select generate_series(1,5);"}
B {"Type":"RowDescription","Fields":[{"Name":"generate_series","TableOID":0,"TableAttributeNumber":0,"DataTypeOID":23,"DataTypeSize":4,"TypeModifier":-1,"Format":0}]}
B {"Type":"DataRow","Values":[{"text":"1"}]}
B {"Type":"DataRow","Values":[{"text":"2"}]}
B {"Type":"DataRow","Values":[{"text":"3"}]}
B {"Type":"DataRow","Values":[{"text":"4"}]}
B {"Type":"DataRow","Values":[{"text":"5"}]}
B {"Type":"CommandComplete","CommandTag":"SELECT 5"}
B {"Type":"ReadyForQuery","TxStatus":"I"}
F {"Type":"Terminate"}
```