![]() ![]() The psycopg2 module supports placeholder using %s signįor example:cursor.execute("insert into people values (%s, %s)", (who, age))Ĭursor.executemany(sql, seq_of_parameters) The SQL statement may be parameterized (i.e., placeholders instead of SQL literals). This routine creates a cursor which will be used throughout of your database programming with Python.Ĭursor.execute(sql ) If database is opened successfully, it returns a connection object. This API opens a connection to the PostgreSQL database. If you are looking for a more sophisticated application, then you can look into Python psycopg2 module's official documentation. The following are important psycopg2 module routines, which can suffice your requirement to work with PostgreSQL database from your Python program. To use psycopg2 module, you must first create a Connection object that represents the database and then optionally you can create cursor object which will help you in executing all the SQL statements. If you do not have it installed on your machine then you can use yum command to install it as follows − You do not need to install this module separately because it is shipped, by default, along with Python version 2.5.x onwards. psycopg2 was written with the aim of being very small and fast, and stable as a rock. sycopg2 is a PostgreSQL database adapter for the Python programming language. The PostgreSQL can be integrated with Python using psycopg2 module. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |