Skip to content

Commit

Permalink
Udpate polars
Browse files Browse the repository at this point in the history
  • Loading branch information
jedewandre committed Oct 16, 2024
1 parent 3c06917 commit 7f68547
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
2 changes: 1 addition & 1 deletion base_external_dbsource_firebird/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"Odoo Community Association (OCA)",
'website': 'https://github.com/OCA/server-tools',
'license': 'LGPL-3',
"external_dependencies": {"python": ["fdb", "pandas"]},
"external_dependencies": {"python": ["fdb", "polars"]},
'depends': [
'base_external_dbsource',
],
Expand Down
21 changes: 9 additions & 12 deletions base_external_dbsource_firebird/models/base_external_dbsource.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,25 @@
try:
import fdb
CONNECTORS.append(('fdb', 'Firebird'))
import pandas as pd
except:
_logger.info('Firebird library not available. Please install "fdb and/or pandas" '
import polars as pl
except ImportError:
_logger.info('Firebird library not available. Please install "fdb and/or polars" '
'python package.')
except ImportError:
_logger.info('base_external_dbsource Odoo module not found.')


class BaseExternalDbsource(models.Model):
""" It provides logic for connection to an Firebird data source. """
""" It provides logic for connection to a Firebird data source. """

_inherit = "base.external.dbsource"

PWD_STRING_FDB = 'Password=%s;'


def connection_close_fdb(self, connection):
self.ensure_one()

return connection.close()


def connection_open_fdb(self):
self.ensure_one()

Expand All @@ -50,9 +47,9 @@ def connection_open_fdb(self):
key, value = option.split('=')
except ValueError:
continue
if key.lower() == "port" :
if key.lower() == "port":
kwargs[key.lower()] = int(value)
else :
else:
kwargs[key.lower()] = value
return fdb.connect(**kwargs)

Expand All @@ -64,8 +61,8 @@ def execute_fdb(self, sqlquery, sqlparams):
cur.execute(sqlquery % sqlparams)
rows = cur.fetchall()
columns = [desc[0] for desc in cur.description]
# Create a DataFrame from the rows and columns
df = pd.DataFrame(rows, columns=columns)

# Create a DataFrame from the rows and columns using Polars
df = pl.DataFrame(rows, schema=columns)

return df
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
# generated from manifests external_dependencies
fdb
mysqlclient
pandas
polars
pymssql<=2.2.5
sqlalchemy

0 comments on commit 7f68547

Please sign in to comment.