Compare commits
No commits in common. "master" and "v0.1a4" have entirely different histories.
8 changed files with 82 additions and 168 deletions
|
@ -1 +0,0 @@
|
||||||
include COPYING.txt
|
|
43
README.md
43
README.md
|
@ -1,43 +0,0 @@
|
||||||
|
|
||||||
# SQLBase7-SA
|
|
||||||
|
|
||||||
SQLBase7-SA is a SQLAlchemy driver/dialect for the Centura SQLBase
|
|
||||||
database, specifically version 7.5.1.
|
|
||||||
|
|
||||||
## About the Project
|
|
||||||
|
|
||||||
From what I can tell, SQLBase is still an actively-developed database,
|
|
||||||
but it is no longer owned by Centura (see
|
|
||||||
[here](http://en.wikipedia.org/wiki/Gupta_Technologies)). Also, the
|
|
||||||
current version (according to [this
|
|
||||||
page](http://www.unify.com/Products/Data_Management/SQLBase/), as of
|
|
||||||
25 Apr 2010) is 11.5, so I have no idea how useful this project will
|
|
||||||
be for versions of SQLBase more recent than 7.5.1.
|
|
||||||
|
|
||||||
This project exists only for the sake of providing read-only access to
|
|
||||||
legacy data, specifically that used by the
|
|
||||||
[CAM32](http://www.camcommerce.com/products/CAM32.aspx) Point of Sale
|
|
||||||
software. It's possible that it could allow writing data, etc., but I
|
|
||||||
personally won't be adding any such features unless/until the need
|
|
||||||
arises.
|
|
||||||
|
|
||||||
I don't expect there to be much of anyone using SQLBase 7.5.1 at this
|
|
||||||
point (besides perhaps other CAM32 users), but if you do happen to
|
|
||||||
need additional functionality from this project or just have questions
|
|
||||||
or comments, feel free to drop me a line at lance@edbob.org.
|
|
||||||
|
|
||||||
## Downloads
|
|
||||||
|
|
||||||
The code is released under the [GNU General Public
|
|
||||||
License](http://www.gnu.org/licenses/gpl.html), version 3.
|
|
||||||
|
|
||||||
It is available at [PyPI](http://pypi.python.org/pypi/SQLBase7-SA), so
|
|
||||||
the easiest way to get the package is with the command:
|
|
||||||
|
|
||||||
# pip install SQLBase7-SA
|
|
||||||
|
|
||||||
Again, this project is extremely specific to my needs, so I'm only
|
|
||||||
building eggs for Python 2.5 and 2.6 at this point. If you happen to
|
|
||||||
need something else then please contact me.
|
|
||||||
|
|
||||||
Copyright © 2010 Lance Edgar <lance@edbob.org>
|
|
40
setup.py
40
setup.py
|
@ -33,52 +33,20 @@ execfile(os.path.join(os.path.dirname(__file__), 'sqlbase7_sa', '_version.py'))
|
||||||
setup(
|
setup(
|
||||||
name = 'SQLBase7-SA',
|
name = 'SQLBase7-SA',
|
||||||
version = __version__,
|
version = __version__,
|
||||||
|
description = 'SQLAlchemy driver/dialect for Centura SQLBase v7',
|
||||||
author = 'Lance Edgar',
|
author = 'Lance Edgar',
|
||||||
author_email = 'lance@edbob.org',
|
author_email = 'lance@edbob.org',
|
||||||
url = "https://forgejo.wuttaproject.org/rattail/sqlbase7-sa",
|
|
||||||
license = "GNU GPL v3",
|
|
||||||
description = 'SQLAlchemy dialect for Centura SQLBase v7',
|
|
||||||
long_description = """
|
|
||||||
SQLBase7-SA - SQLAlchemy dialect for Centura SQLBase v7
|
|
||||||
-------------------------------------------------------
|
|
||||||
|
|
||||||
This package provides a (possibly rudimentary) implementation
|
|
||||||
of a SQLAlchemy dialect for the Centura SQLBase database
|
|
||||||
engine. It is only intended (and known) to work with a very
|
|
||||||
specific version of this database, that version being 7.5.1.
|
|
||||||
""",
|
|
||||||
|
|
||||||
classifiers = [
|
|
||||||
'Development Status :: 4 - Beta',
|
|
||||||
'Environment :: Plugins',
|
|
||||||
'Environment :: Win32 (MS Windows)',
|
|
||||||
'Intended Audience :: Developers',
|
|
||||||
'License :: OSI Approved :: GNU General Public License (GPL)',
|
|
||||||
'Natural Language :: English',
|
|
||||||
'Operating System :: Microsoft :: Windows',
|
|
||||||
'Programming Language :: Python',
|
|
||||||
'Programming Language :: Python :: 2.5',
|
|
||||||
'Programming Language :: Python :: 2.6',
|
|
||||||
'Topic :: Database',
|
|
||||||
'Topic :: Software Development :: Libraries :: Python Modules',
|
|
||||||
],
|
|
||||||
|
|
||||||
packages = find_packages(),
|
packages = find_packages(),
|
||||||
|
|
||||||
install_requires = [
|
install_requires = [
|
||||||
'SQLAlchemy>0.5.2',
|
'SQLAlchemy>=0.5,<=0.6.99',
|
||||||
],
|
],
|
||||||
|
|
||||||
|
# This is only used by SQLAlchemy 0.6.
|
||||||
entry_points = {
|
entry_points = {
|
||||||
|
|
||||||
# SQLAlchemy 0.5
|
|
||||||
'sqlalchemy.databases' : [
|
|
||||||
'sqlbase7 = sqlbase7_sa.sqlbase7_sa05:SQLBase7Dialect_SA05',
|
|
||||||
],
|
|
||||||
|
|
||||||
# SQLAlchemy 0.6
|
|
||||||
'sqlalchemy.dialects' : [
|
'sqlalchemy.dialects' : [
|
||||||
'sqlbase7 = sqlbase7_sa.sqlbase7_sa06:SQLBase7Dialect_SA06_pyodbc',
|
'sqlbase7 = sqlbase7_sa:base.dialect',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -24,3 +24,25 @@
|
||||||
|
|
||||||
|
|
||||||
from sqlbase7_sa._version import __version__
|
from sqlbase7_sa._version import __version__
|
||||||
|
|
||||||
|
import sqlalchemy
|
||||||
|
from pkg_resources import parse_version
|
||||||
|
|
||||||
|
|
||||||
|
if parse_version(sqlalchemy.__version__) <= parse_version('0.5.99'):
|
||||||
|
|
||||||
|
# SQLAlchemy 0.5 doesn't support user-contributed dialects "directly"
|
||||||
|
# by way of setuptools entry points, so we must monkey-patch it in
|
||||||
|
# order to add ours.
|
||||||
|
import sqlalchemy.databases, sqlbase7_sa, sys
|
||||||
|
sqlalchemy.databases.sqlbase7 = sqlbase7_sa
|
||||||
|
sys.modules['sqlalchemy.databases.sqlbase7'] = sqlbase7_sa
|
||||||
|
|
||||||
|
# SQLAlchemy will be expecting us to have a 'dialect' attribute.
|
||||||
|
import sqlbase7_sa.sqlbase7_sa05
|
||||||
|
dialect = sqlbase7_sa.sqlbase7_sa05.SQLBase7Dialect_SA05
|
||||||
|
|
||||||
|
else:
|
||||||
|
# SQLAlchemy 0.6 is much nicer to play with.
|
||||||
|
import sqlbase7_sa.sqlbase7_sa06
|
||||||
|
base = sqlbase7_sa.sqlbase7_sa06
|
||||||
|
|
|
@ -23,4 +23,4 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
|
|
||||||
__version__ = '0.1b5'
|
__version__ = '0.1a4'
|
||||||
|
|
|
@ -26,7 +26,6 @@
|
||||||
from sqlalchemy.engine.default import DefaultDialect
|
from sqlalchemy.engine.default import DefaultDialect
|
||||||
from sqlalchemy import types, and_
|
from sqlalchemy import types, and_
|
||||||
from sqlalchemy.sql.expression import Join
|
from sqlalchemy.sql.expression import Join
|
||||||
from sqlalchemy.sql import visitors, operators, ClauseElement
|
|
||||||
|
|
||||||
|
|
||||||
import sqlalchemy
|
import sqlalchemy
|
||||||
|
@ -57,12 +56,7 @@ class SQLBase7Compiler(CompilerBase):
|
||||||
return self.process(join.left, **kwargs) + ", " + self.process(join.right, **kwargs)
|
return self.process(join.left, **kwargs) + ", " + self.process(join.right, **kwargs)
|
||||||
|
|
||||||
def visit_select(self, select, **kwargs):
|
def visit_select(self, select, **kwargs):
|
||||||
if self.stack and 'from' in self.stack[-1]:
|
froms = select._get_display_froms()
|
||||||
existingfroms = self.stack[-1]['from']
|
|
||||||
else:
|
|
||||||
existingfroms = None
|
|
||||||
|
|
||||||
froms = select._get_display_froms(existingfroms)
|
|
||||||
whereclause = self._get_join_whereclause(froms)
|
whereclause = self._get_join_whereclause(froms)
|
||||||
if whereclause is not None:
|
if whereclause is not None:
|
||||||
select = select.where(whereclause)
|
select = select.where(whereclause)
|
||||||
|
@ -77,15 +71,6 @@ class SQLBase7Compiler(CompilerBase):
|
||||||
clauses = []
|
clauses = []
|
||||||
|
|
||||||
def visit_join(join):
|
def visit_join(join):
|
||||||
if join.isouter:
|
|
||||||
def visit_binary(binary):
|
|
||||||
if binary.operator == operators.eq:
|
|
||||||
if binary.left.table is join.right:
|
|
||||||
binary.left = _OuterJoinColumn(binary.left)
|
|
||||||
elif binary.right.table is join.right:
|
|
||||||
binary.right = _OuterJoinColumn(binary.right)
|
|
||||||
clauses.append(visitors.cloned_traverse(join.onclause, {}, {'binary':visit_binary}))
|
|
||||||
else:
|
|
||||||
clauses.append(join.onclause)
|
clauses.append(join.onclause)
|
||||||
for j in join.left, join.right:
|
for j in join.left, join.right:
|
||||||
if isinstance(j, Join):
|
if isinstance(j, Join):
|
||||||
|
@ -99,16 +84,6 @@ class SQLBase7Compiler(CompilerBase):
|
||||||
return and_(*clauses)
|
return and_(*clauses)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def visit_outer_join_column(self, vc):
|
|
||||||
return self.process(vc.column) + "(+)"
|
|
||||||
|
|
||||||
|
|
||||||
class _OuterJoinColumn(ClauseElement):
|
|
||||||
__visit_name__ = 'outer_join_column'
|
|
||||||
|
|
||||||
def __init__(self, column):
|
|
||||||
self.column = column
|
|
||||||
|
|
||||||
|
|
||||||
class SQLBase7Dialect(DefaultDialect):
|
class SQLBase7Dialect(DefaultDialect):
|
||||||
|
|
||||||
|
|
|
@ -25,23 +25,16 @@
|
||||||
|
|
||||||
from sqlalchemy import types, Column, PrimaryKeyConstraint
|
from sqlalchemy import types, Column, PrimaryKeyConstraint
|
||||||
from sqlalchemy.sql.compiler import OPERATORS
|
from sqlalchemy.sql.compiler import OPERATORS
|
||||||
from sqlalchemy.sql import operators as sql_operators
|
from sqlalchemy.sql import operators
|
||||||
|
|
||||||
from sqlbase7_sa.sqlbase7 import SQLBase7Compiler, SQLBase7Dialect
|
from sqlbase7_sa.sqlbase7 import SQLBase7Dialect
|
||||||
|
|
||||||
|
|
||||||
class SQLBase7Compiler_SA05(SQLBase7Compiler):
|
OPERATORS[operators.ilike_op] = lambda x, y, escape=None: "@lower(%s) LIKE @lower(%s)" % (x, y) + (escape and ' ESCAPE \'%s\'' % escape or '')
|
||||||
|
|
||||||
operators = SQLBase7Compiler.operators.copy()
|
|
||||||
operators.update({
|
|
||||||
sql_operators.ilike_op: lambda x, y, escape=None: "@lower(%s) LIKE @lower(%s)" % (x, y) + (escape and ' ESCAPE \'%s\'' % escape or ''),
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
class SQLBase7Dialect_SA05(SQLBase7Dialect):
|
class SQLBase7Dialect_SA05(SQLBase7Dialect):
|
||||||
|
|
||||||
statement_compiler = SQLBase7Compiler_SA05
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def dbapi(cls):
|
def dbapi(cls):
|
||||||
import pyodbc
|
import pyodbc
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue