question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TAIL is handled as a non-standard COPY TO statement

See original GitHub issue

Trying to get node-postgres working with a streaming database that uses the postgres protocol. From the docs I cut a section and added it below. Having trouble getting it to work. Does this driver support something like cursor.copy_expert("TAIL some_materialized_view", sys.stdout)?

In terms of the pgwire protocol, TAIL is handled as a non-standard COPY TO statement. As long as your driver lets you send your own COPY statement to the running Materialize node, you can TAIL updates from Materialize anywhere you’d like.
#!/usr/bin/env python3

import sys
import psycopg2

def main():

    dsn = 'postgresql://localhost:6875/materialize?sslmode=disable'
    conn = psycopg2.connect(dsn)

    with conn.cursor() as cursor:
        cursor.copy_expert("TAIL some_materialized_view", sys.stdout)

if __name__ == '__main__':
    main()

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
charmandercommented, Aug 7, 2020

The pg-query-stream README references pg.connect, but it’s out of date. You should connect a client as shown at https://node-postgres.com/features/connecting/. The query stream might work then.

@vitaly-t “cursor” in the Python code refers to a PEP 249 cursor, not a PostgreSQL cursor.

I was thinking of pg-copy-streams, not pg-query-stream. pg-query-stream is a wrapper for pg-cursor. You want pg-copy-streams.

0reactions
timcashcommented, Aug 15, 2020

Ill try this out and report back

Read more comments on GitHub >

github_iconTop Results From Across the Web

Linux: write tail -f output, plus comments, to a separate text file
For record purposes, I would like to be able to pipe the tail output to terminal, plus my annotations, to a second file....
Read more >
20.8. Error Reporting and Logging - PostgreSQL
Unrecognized escapes are ignored. Other characters are copied straight to the log line. Some escapes are only recognized by session processes, and will...
Read more >
Why does Mozilla consider Conditional catch-blocks non-standard ...
Non-standard This feature is non-standard and is not on a standards track. ... TypeError) { // statements to handle TypeError exceptions } catch...
Read more >
RFC 6241: Network Configuration Protocol (NETCONF)
For example, user files and databases are not treated as configuration ... A NETCONF message MAY begin with an XML declaration (see Section...
Read more >
Comparison of different SQL implementations - Troels
DB2 allows you to copy the structure of a view into a table. ... Due to Oracle's non-standard NULL-handling, you may get strange...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found