qal.dal package

Submodules

qal.dal.conversions module

Created on Sep 23, 2013

@author: Nicklas Boerjesson

qal.dal.conversions.MySQL_GEOMETRY = 255

Translation methods for MySQL field codes into the SQL data types(qal.sql.types): return [‘integer’, ‘string’, ‘string(255)’, ‘string(3000)’, ‘float’, ‘serial’, ‘timestamp’, ‘boolean’]

Arguably, they should be declared in qal.dal.types instead.

qal.dal.conversions.mysql_type_to_SQL_type(_type_code)[source]

Convert the internal MySQL type to the SQL type

Parameters:_type_code – A MySQL field constant
qal.dal.conversions.parse_description(_descriptions, _db_type)[source]

Convert field descriptions to field name- and field type-lists.

Parameters:
  • _descriptions – A list of descriptions
  • _db_type – The database type
qal.dal.conversions.python_type_to_SQL_type(_python_type)[source]

Convert a python data type to ab SQL type.

Parameters:_python_type – A Python internal type

qal.dal.dal module

qal.dal - Database Abstraction Layer

The goal with DAL is to hide the connection-related differences between the most common database backends.

copyright:Copyright 2010-2014 by Nicklas Boerjesson
license:BSD, see LICENSE for details.
class qal.dal.dal.DatabaseAbstractionLayer(_settings=None, _resource=None)[source]

Bases: builtins.object

This class abstracts the different peculiarities of the different database backends with regards to connection details

close()[source]

Close the database connection

commit()[source]

Commit the transaction

connect_to_db()[source]

Connects to the database

connected = False

Is true if connected

db_autocommit = True

Autocommit. If True, the SQL is committed immidiately, if False, commit needs to be called to commit changes.

db_connection = None

The database connection

db_databasename = ''

Database name

db_driver = None

Database driver

db_instance = ''

Instance

db_password = ''

Password

db_port = None

The TCP port of the database server

db_server = ''

Server name

db_type = None

Database type

db_username = ''

Username

execute(_sql)[source]

Execute the SQL statement, expect no dataset

executemany(_sql, _values)[source]

Execute the SQL statements , expect no dataset

field_names = None

The field names of the dataset

field_types = None

The field types of the fields as defined in conversions.py

on_connect = None

Triggered on connect

query(_sql)[source]

Execute the SQL statement, get a dataset

read_ini_settings(_ini_parser)[source]

Read setting from the settings. :param _ini_parser: ConfigParser object

read_resource_settings(_resource)[source]

Read settings from a resource object :param _resource: A resource object

rollback()[source]

Rollback the transaction

start()[source]

Start transaction

write_resource_settings(_resource)[source]

Write settings to a resource object :param _resource: A resource object.

qal.dal.types module

Created on Aug 17, 2010

@author: Nicklas Boerjesson

qal.dal.types.db_type_to_string(_DBType)[source]

Returns string matching the specified db_type constant

qal.dal.types.db_types()[source]

Returns a list of supported database engines

qal.dal.types.string_to_db_type(_value)[source]

Returns db_type constant matching the specified string

qal.dal.types.unenumerate(value, _Type)[source]

Returns the value of a specific item

Module contents

qal.dal - Database Abstraction Layer

The goal with the DAL package is to hide the connection-related differences between the most common RDBMS database backends. Supported platforms are (qal.dal.types) : MySQL, PostgreSQL, Oracle, DB2 and SQL server

copyright:Copyright 2010-2014 by Nicklas Boerjesson
license:BSD, see LICENSE for details.