**************************************************
Python Core PlayList : • Lesson - 01 : Python3 - What is python
Python Advanced PlayList : • Lesson - 46 : Python Advanced - Pytho...
**************************************************
Python Database Access : Connecting to Postgresql Databases:
Connect to the Postgres Database using authentication. Catch and print a connection error if one occurs.
#!/usr/bin/python
import psycopg2
import sys
def main():
#Define our connection string
conn_string = "host='localhost' dbname='my_database' user='postgres' password='secret'"
print the connection string we will use to connect
print "Connecting to database\n ->%s" % (conn_string)
get a connection, if a connect cannot be made an exception will be raised here
conn = psycopg2.connect(conn_string)
conn.cursor will return a cursor object, you can use this cursor to perform queries
cursor = conn.cursor()
print "Connected!\n"
if _name_ == "__main__":
main()
Sample Projects : https://github.com/SadaLearningHub1/P...
In questa pagina del sito puoi guardare il video online Lesson - 60 : Python Advanced - Python Database Access : Connecting to Postgresql Databases della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Sada Learning Hub 17 gennaio 2018, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 348 volte e gli è piaciuto 2 spettatori. Buona visione!