Comments (9)
I am also experiencing this issue. Sorry I don't have anything more to add (Postgresql 9.3)
from dataset.
Fixed in a95c7be
from dataset.
Thanks!
from dataset.
I'm still experiencing the same issue here.
>>> db = dataset.connect(os.environ["DB_URL"], schema="1")
>>> table = db['person']
>>> print(table.columns)
['id']
>>> table.insert(dict(name='John Doe', age=46))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/Jens/Dropbox/journalism++/jsurveillance/Scraper/env/lib/python2.7/site-packages/dataset/persistence/table.py", line 72, in insert
self._ensure_columns(row, types=types)
File "/Users/Jens/Dropbox/journalism++/jsurveillance/Scraper/env/lib/python2.7/site-packages/dataset/persistence/table.py", line 214, in _ensure_columns
self.create_column(column, _type)
File "/Users/Jens/Dropbox/journalism++/jsurveillance/Scraper/env/lib/python2.7/site-packages/dataset/persistence/table.py", line 241, in create_column
Column(name, type)
File "/Users/Jens/Dropbox/journalism++/jsurveillance/Scraper/env/lib/python2.7/site-packages/alembic/operations.py", line 595, in add_column
schema=schema
File "/Users/Jens/Dropbox/journalism++/jsurveillance/Scraper/env/lib/python2.7/site-packages/alembic/ddl/impl.py", line 176, in add_column
self._exec(base.AddColumn(table_name, column, schema=schema))
File "/Users/Jens/Dropbox/journalism++/jsurveillance/Scraper/env/lib/python2.7/site-packages/alembic/ddl/impl.py", line 122, in _exec
return conn.execute(construct, *multiparams, **params)
File "/Users/Jens/Dropbox/journalism++/jsurveillance/Scraper/env/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1989, in execute
return connection.execute(statement, *multiparams, **params)
File "/Users/Jens/Dropbox/journalism++/jsurveillance/Scraper/env/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 914, in execute
return meth(self, multiparams, params)
File "/Users/Jens/Dropbox/journalism++/jsurveillance/Scraper/env/lib/python2.7/site-packages/sqlalchemy/sql/ddl.py", line 68, in _execute_on_connection
return connection._execute_ddl(self, multiparams, params)
File "/Users/Jens/Dropbox/journalism++/jsurveillance/Scraper/env/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 968, in _execute_ddl
compiled
File "/Users/Jens/Dropbox/journalism++/jsurveillance/Scraper/env/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1146, in _execute_context
context)
File "/Users/Jens/Dropbox/journalism++/jsurveillance/Scraper/env/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1341, in _handle_dbapi_exception
exc_info
File "/Users/Jens/Dropbox/journalism++/jsurveillance/Scraper/env/lib/python2.7/site-packages/sqlalchemy/util/compat.py", line 199, in raise_from_cause
reraise(type(exception), exception, tb=exc_tb)
File "/Users/Jens/Dropbox/journalism++/jsurveillance/Scraper/env/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1139, in _execute_context
context)
File "/Users/Jens/Dropbox/journalism++/jsurveillance/Scraper/env/lib/python2.7/site-packages/sqlalchemy/engine/default.py", line 450, in do_execute
cursor.execute(statement, parameters)
sqlalchemy.exc.ProgrammingError: (psycopg2.ProgrammingError) relation "person" does not exist
[SQL: 'ALTER TABLE person ADD COLUMN age INTEGER']
from dataset.
Yes, me too. I'm going to try and make a test for this.
from dataset.
I can fix this one issue by specifying the schema in create_column
of table.py
def create_column(self, name, type):
"""
Explicitely create a new column ``name`` of a specified type.
``type`` must be a `SQLAlchemy column type <http://docs.sqlalchemy.org/en/rel_0_8/core/types.html>`_.
::
table.create_column('created_at', sqlalchemy.DateTime)
"""
self._check_dropped()
self.database._acquire()
try:
if normalize_column_name(name) not in self._normalized_columns:
self.database.op.add_column(
self.table.name,
Column(name, type),
self.table.schema
)
self.table = self.database.update_table(self.table.name)
finally:
self.database._release()
However, running the complete test_persistence.py when connected to a specific postgres schema has more problems.
======================================================================
ERROR: test_query (test.test_persistence_pg.DatabaseTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "test/test_persistence_pg.py", line 135, in test_query
r = self.db.query('SELECT COUNT(*) AS num FROM weather').next()
File "dataset/persistence/database.py", line 294, in query
return ResultIter(self.executable.execute(query, **kw),
File "/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1989, in execute
return connection.execute(statement, *multiparams, **params)
File "/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 914, in execute
return meth(self, multiparams, params)
File "/usr/local/lib/python2.7/site-packages/sqlalchemy/sql/elements.py", line 323, in _execute_on_connection
return connection._execute_clauseelement(self, multiparams, params)
File "/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1010, in _execute_clauseelement
compiled_sql, distilled_params
File "/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1146, in _execute_context
context)
File "/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1341, in _handle_dbapi_exception
exc_info
File "/usr/local/lib/python2.7/site-packages/sqlalchemy/util/compat.py", line 199, in raise_from_cause
reraise(type(exception), exception, tb=exc_tb)
File "/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1139, in _execute_context
context)
File "/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/default.py", line 450, in do_execute
cursor.execute(statement, parameters)
ProgrammingError: (psycopg2.ProgrammingError) relation "weather" does not exist
LINE 1: SELECT COUNT(*) AS num FROM weather
^
[SQL: 'SELECT COUNT(*) AS num FROM weather']
Sending a plain query text string fails unless table names in the string are schema qualified. This makes sense and https://stackoverflow.com/questions/9298296/sqlalchemy-support-of-postgres-schemas has some ideas on how to deal with it. I tried the to set the path via event listener but the test seems to be creating too many connections and postgres complains.
Also, the test has failures like this when connected to postgres
======================================================================
ERROR: test_find_one (test.test_persistence_pg.RowTypeTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "test/test_persistence_pg.py", line 372, in test_find_one
assert d.temperature == -10, d
AttributeError: 'OrderedDict' object has no attribute 'temperature'
Maybe just a setting somewhere in sqlalchemy or psycopg2 to get the query results accessible as properties but I'm leaving this for now.
from dataset.
Hi all , wondering if you can help, i can't find how to specify the schema to make my inserts, im using postgres. Thank you for all the great work with dataset
from dataset.
@jvidin I've incorporated the fix suggested by @smnorris - can you check that fixes the issue for you, as well?
from dataset.
Fixed.
from dataset.
Related Issues (20)
- inconsistent Upsert documentation HOT 3
- Increase a value without reading last value
- create_table error when source data has ID field
- SQL Alchemy links in docs broken
- CompileError at `update_many` due to column in a dataset doesn't exist in a db HOT 2
- TypeError: MetaData.__init__() got an unexpected keyword argument 'bind' under sqlalchemy 2.0 HOT 1
- Looking for help: migrating dataset to sqla 2.0.0 HOT 4
- Remove duplicates from a table
- Dataset ignore my primary key HOT 3
- SQLAlchemy examples in the doc
- Parameter passing exception
- dataset wrapper for With statement HOT 3
- bug with alembic=1.11 HOT 1
- Warn if user accidentally uses set as advanced filter?
- Current use of Database.op.add_column() does not work with later versions of alembic HOT 1
- Why doesn't it automatically recycle connections in the connection pool? HOT 1
- Python 3.11 HOT 2
- where HOT 1
- add_column() takes 3 positional arguments but 4 were given HOT 1
- can add query log ? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dataset.