Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python3
- import time
- import psycopg2
- import sys
- def main():
- # Get a connection
- conn = psycopg2.connect(database='my_db', host='10.10.2.1', port='5433', user='me', password='my_password_that_i_dont_show_here')
- # conn.cursor will return a cursor object, to perform queries
- cursor = conn.cursor()
- # Execute our query
- cursor.execute("select date(created_at), email, firstname, lastname, locale from users where date(created_at) = current_date;")
- # retrieve the records from the database
- records = cursor.fetchall()
- print(records)
- if __name__ == "__main__":
- main()
- Traceback (most recent call last):
- File "Bureau/script.py", line 29, in <module>
- main()
- File "Bureau/script.py", line 15, in main
- conn = psycopg2.connect(database='my_db', host='10.10.2.1', port='5433', user='me', password='best_password_ever')
- File "/usr/local/lib/python3.5/dist-packages/psycopg2/__init__.py", line 164, in connect
- conn = _connect(dsn, connection_factory=connection_factory, async=async)
- psycopg2.OperationalError: could not connect to server: Connection timed out
- Is the server running on host "10.10.2.1" and accepting
- TCP/IP connections on port 5433?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement