<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>OpenText Analytics Database 26.2.x – Python</title>
    <link>/en/connecting-to/client-libraries/accessing/python/</link>
    <description>Recent content in Python on OpenText Analytics Database 26.2.x</description>
    <generator>Hugo -- gohugo.io</generator>
    
	  <atom:link href="/en/connecting-to/client-libraries/accessing/python/index.xml" rel="self" type="application/rss+xml" />
    
    
      
        
      
    
    
    <item>
      <title>Connecting-To: Configuring the ODBC run-time environment on Linux</title>
      <link>/en/connecting-to/client-libraries/accessing/python/configuring-odbc-run-time-environment-on-linux/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/connecting-to/client-libraries/accessing/python/configuring-odbc-run-time-environment-on-linux/</guid>
      <description>
        
        
        &lt;p&gt;To configure the ODBC run-time environment on Linux:
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Create the &lt;code&gt;odbc.ini&lt;/code&gt; file if it does not already exist.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Add the ODBC driver directory to the LD_LIBRARY_PATH system environment variable:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;export LD_LIBRARY_PATH=/path-to-vertica-odbc-driver:$LD_LIBRARY_PATH
&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&#34;admonition important&#34; role=&#34;alert&#34;&gt;
&lt;h4 class=&#34;admonition-head&#34;&gt;Important&lt;/h4&gt;
If you skip Step 2, the ODBC manager cannot find the driver in order to load it.
&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;These steps are relevant only for unixODBC and iODBC. See their respective documentation for details on &lt;code&gt;odbc.ini&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id=&#34;see-also&#34;&gt;See also&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&#34;http://www.unixodbc.org/&#34;&gt;unixODBC Web site&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&#34;http://www.iodbc.org/dataspace/iodbc/wiki/iODBC/&#34;&gt;iODBC Web site&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

      </description>
    </item>
    
    <item>
      <title>Connecting-To: Querying the database with pyodbc</title>
      <link>/en/connecting-to/client-libraries/accessing/python/querying-db-with-pyodbc/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/connecting-to/client-libraries/accessing/python/querying-db-with-pyodbc/</guid>
      <description>
        
        
        &lt;p&gt;The example session below uses pyodbc with the OpenText™ Analytics Database ODBC driver to connect Python to the database.

&lt;div class=&#34;alert admonition note&#34; role=&#34;alert&#34;&gt;
&lt;h4 class=&#34;admonition-head&#34;&gt;Note&lt;/h4&gt;

SQLFetchScroll and SQLFetch functions cannot be mixed together in iODBC code. When using pyodbc with the iODBC driver manager, skip cannot be used with the fetchall, fetchone, and fetchmany functions.

&lt;/div&gt;&lt;/p&gt;
&lt;h2 id=&#34;example-script&#34;&gt;Example script&lt;/h2&gt;
&lt;p&gt;The following example script shows how to query the database using Python 3, pyodbc, and an ODBC DSN.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;
import pyodbc
cnxn = pyodbc.connect(&amp;#34;DSN=VerticaDSN&amp;#34;, ansi=True)
cursor = cnxn.cursor()
# create table
cursor.execute(&amp;#34;CREATE TABLE TEST(&amp;#34;
    &amp;#34;C_ID  INT,&amp;#34;
    &amp;#34;C_FP  FLOAT,&amp;#34;
    &amp;#34;C_VARCHAR VARCHAR(100),&amp;#34;
    &amp;#34;C_DATE DATE, C_TIME TIME,&amp;#34;
    &amp;#34;C_TS TIMESTAMP,&amp;#34;
    &amp;#34;C_BOOL BOOL)&amp;#34;)
cursor.execute(&amp;#34;INSERT INTO test VALUES(1,1.1,&amp;#39;abcdefg1234567890&amp;#39;,&amp;#39;1901-01-01&amp;#39;,&amp;#39;23:12:34&amp;#39;,&amp;#39;1901-01-01 09:00:09&amp;#39;,&amp;#39;t&amp;#39;)&amp;#34;)
cursor.execute(&amp;#34;INSERT INTO test VALUES(2,3.4,&amp;#39;zxcasdqwe09876543&amp;#39;,&amp;#39;1991-11-11&amp;#39;,&amp;#39;00:00:01&amp;#39;,&amp;#39;1981-12-31 19:19:19&amp;#39;,&amp;#39;f&amp;#39;)&amp;#34;)
cursor.execute(&amp;#34;SELECT * FROM TEST&amp;#34;)
rows = cursor.fetchall()
for row in rows:
    print(row, end=&amp;#39;\n&amp;#39;)
cursor.execute(&amp;#34;DROP TABLE TEST CASCADE&amp;#34;)
cursor.close()
cnxn.close()
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The resulting output displays:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;(2, 3.4, &amp;#39;zxcasdqwe09876543&amp;#39;, datetime.date(1991, 11, 11), datetime.time(0, 0, 1), datetime.datetime(1981, 12, 31, 19, 19, 19), False)
(1, 1.1, &amp;#39;abcdefg1234567890&amp;#39;, datetime.date(1901, 1, 1), datetime.time(23, 12, 34), datetime.datetime(1901, 1, 1, 9, 0, 9), True)
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;notes&#34;&gt;Notes&lt;/h2&gt;
&lt;p&gt;SQLPrimaryKeys returns the table name in the primary (&lt;code&gt;pk_name&lt;/code&gt;) column for unnamed primary constraints. For example:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Unnamed primary key:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;CREATE TABLE schema.test(c INT PRIMARY KEY);

SQLPrimaryKeys
&amp;#34;TABLE_CAT&amp;#34;, &amp;#34;TABLE_SCHEM&amp;#34;, &amp;#34;TABLE_NAME&amp;#34;, &amp;#34;COLUMN_NAME&amp;#34;, &amp;#34;KEY_SEQ&amp;#34;, &amp;#34;PK_NAME&amp;#34; &amp;lt;Null&amp;gt;, &amp;#34;SCHEMA&amp;#34;, &amp;#34;TEST&amp;#34;, &amp;#34;C&amp;#34;, 1, &amp;#34;TEST&amp;#34;
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Named primary key:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;CREATE TABLE schema.test(c INT CONSTRAINT pk_1 PRIMARY KEY);

SQLPrimaryKeys
&amp;#34;TABLE_CAT&amp;#34;, &amp;#34;TABLE_SCHEM&amp;#34;, &amp;#34;TABLE_NAME&amp;#34;, &amp;#34;COLUMN_NAME&amp;#34;, &amp;#34;KEY_SEQ&amp;#34;, &amp;#34;PK_NAME&amp;#34; &amp;lt;Null&amp;gt;, &amp;#34;SCHEMA&amp;#34;, &amp;#34;TEST&amp;#34;, &amp;#34;C&amp;#34;, 1, &amp;#34;PK_1&amp;#34;
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;OpenText recommends that you name your constraints.&lt;/p&gt;
&lt;h2 id=&#34;see-also&#34;&gt;See also&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;../../../../../en/connecting-to/client-libraries/accessing/ccpp/loading-data/#&#34;&gt;Loading data&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

      </description>
    </item>
    
  </channel>
</rss>
