Re: [sqlalchemy] Declarative: defining relationship and column in one line

2015-05-31 Thread Mike Bayer



On 5/31/15 6:11 AM, Fayaz Yusuf Khan wrote:

Hi,

On Tuesday, May 19, 2015 at 7:41:45 PM UTC+5:30, Michael Bayer wrote:


http://techspot.zzzeek.org/2011/05/17/magic-a-new-orm/
http://techspot.zzzeek.org/2011/05/17/magic-a-new-orm/

I had tried this one before but it looked like those columns were 
never added to the underlying table.


I just ran the magic.py example from the blog post against SQLA 1.0.4 
and it worked fine.





--
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


Re: [sqlalchemy] Support for pysqlcipher3

2015-05-31 Thread Mike Bayer



On 5/31/15 4:23 AM, Fayaz Yusuf Khan wrote:

Hi,

pysqlcipher3 is a Python3 port for pysqlcipher (for SQLite). Does SQLA 
currently have support for this? (I wasn't able to get it running for 
my project.)

If not, any chances it will, in the future?


pysqlcipher is right here:

http://docs.sqlalchemy.org/en/rel_1_0/dialects/sqlite.html#module-sqlalchemy.dialects.sqlite.pysqlcipher

SQLAlchemy supports Python 2K and Python 3K in place though the above 
dialect has probably not been tested on Py3K.



Which means.  I wasn't able to get it running == ask for help w/ your 
specific issue and/or report a bug.



--
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


Re: Autogenerate - unknown table popping up in sqlalchemy.exc.NoSuchTableError

2015-05-31 Thread Mike Bayer



On 5/31/15 7:00 PM, Wavemaker wrote:
Well, upon digging further myself, I noticed that was an old foreign 
key in my Pictures table referring to the non-existant auth_user table:
 sql: last_changed_user_id integer NOT NULL REFERENCES 
auth_user (id)
This was not referenced anymore in the model. So, I guess that in 
order to use alembic properly I should not have manually deleted that 
table (in fact I did that before starting to use alembic), but to 
remove both the table and the foreign key in the model and then let 
alembic apply both changes to the database in one go. Correct?


that doesn't make too much sense because a relational database can't 
have a FOREIGN KEY to a table that doesn't exist. *unless* this is 
SQLite, which is just an odd case.   feel free to manually delete 
whatever tables you want, you just need to make sure you keep track of 
what's going on when you point a schema reflection tool at that database 
at some later point.



For reference purposes still find here the complete stack trace 
without having the solution applied yet. Note again that I inserted 
some debug statements here and there in the sqlalchemy/alembic code, 
so line numbers may deviate.


Traceback (most recent call last):
  File virtualenv\Scripts\alembic-script.py, line 11, in module
load_entry_point('alembic==0.7.6', 'console_scripts', 'alembic')()
  File F:\Workspace\MyProject\src\virtualenv\Lib\site-packages\alembi
c\config.py, line 439, in main
CommandLine(prog=prog).main(argv=argv)
  File F:\Workspace\MyProject\src\virtualenv\Lib\site-packages\alembi
c\config.py, line 433, in main
self.run_cmd(cfg, options)
  File F:\Workspace\MyProject\src\virtualenv\Lib\site-packages\alembi
c\config.py, line 416, in run_cmd
**dict((k, getattr(options, k)) for k in kwarg)
  File F:\Workspace\MyProject\src\virtualenv\Lib\site-packages\alembi
c\command.py, line 113, in revision
script.run_env()
  File F:\Workspace\MyProject\src\virtualenv\Lib\site-packages\alembi
c\script.py, line 390, in run_env
util.load_python_file(self.dir, 'env.py')
  File F:\Workspace\MyProject\src\virtualenv\Lib\site-packages\alembi
c\util.py, line 243, in load_python_file
module = load_module_py(module_id, path)
  File F:\Workspace\MyProject\src\virtualenv\Lib\site-packages\alembi
c\compat.py, line 79, in load_module_py
mod = imp.load_source(module_id, path, fp)
  File alembic\env.py, line 99, in module
run_migrations_online()
  File alembic\env.py, line 92, in run_migrations_online
context.run_migrations()
  File string, line 7, in run_migrations
  File F:\Workspace\MyProject\src\virtualenv\Lib\site-packages\alembi
c\environment.py, line 738, in run_migrations
self.get_context().run_migrations(**kw)
  File F:\Workspace\MyProject\src\virtualenv\Lib\site-packages\alembi
c\migration.py, line 300, in run_migrations
for step in self._migrations_fn(heads, self):
  File F:\Workspace\MyProject\src\virtualenv\Lib\site-packages\alembi
c\command.py, line 95, in retrieve_migrations
autogen._produce_migration_diffs(context, template_args, imports)
  File F:\Workspace\MyProject\src\virtualenv\Lib\site-packages\alembi
c\autogenerate\api.py, line 154, in _produce_migration_diffs
autogen_context, object_filters, include_schemas)
  File F:\Workspace\MyProject\src\virtualenv\Lib\site-packages\alembi
c\autogenerate\api.py, line 256, in _produce_net_changes
inspector, metadata, diffs, autogen_context)
  File F:\Workspace\MyProject\src\virtualenv\Lib\site-packages\alembi
c\autogenerate\compare.py, line 84, in _compare_tables
inspector.reflecttable(t, None)
  File F:\Workspace\MyProject\src\virtualenv\Lib\site-packages\sqlalc
hemy\engine\reflection.py, line 590, in reflecttable
exclude_columns, reflection_options)
  File F:\Workspace\MyProject\src\virtualenv\Lib\site-packages\sqlalc
hemy\engine\reflection.py, line 720, in _reflect_fk
**reflection_options
  File F:\Workspace\MyProject\src\virtualenv\Lib\site-packages\sqlalc
hemy\sql\schema.py, line 441, in __new__
metadata._remove_table(name, schema)
  File F:\Workspace\MyProject\src\virtualenv\Lib\site-packages\sqlalc
hemy\util\langhelpers.py, line 60, in __exit__
compat.reraise(exc_type, exc_value, exc_tb)
  File F:\Workspace\MyProject\src\virtualenv\Lib\site-packages\sqlalc
hemy\sql\schema.py, line 432, in __new__
table._init(name, metadata, *args, **kw)
  File F:\Workspace\MyProject\src\virtualenv\Lib\site-packages\sqlalc
hemy\sql\schema.py, line 513, in _init
self._autoload(metadata, autoload_with, include_columns)
  File F:\Workspace\MyProject\src\virtualenv\Lib\site-packages\sqlalc
hemy\sql\schema.py, line 528, in _autoload
self, include_columns, exclude_columns
  File F:\Workspace\MyProject\src\virtualenv\Lib\site-packages\sqlalc
hemy\engine\base.py, line 1481, in run_callable
return callable_(self, *args, **kwargs)
  File F:\Workspace\MyProject\src\virtualenv\Lib\site-packages\sqlalc
hemy\engine\default.py, 

Re: [sqlalchemy] Support for pysqlcipher3

2015-05-31 Thread Fayaz Yusuf Khan
On Sunday 31 May 2015 11:06:32 AM Mike Bayer wrote:
 pysqlcipher is right here:
 
 http://docs.sqlalchemy.org/en/rel_1_0/dialects/sqlite.html#module-sqlalchemy
 .dialects.sqlite.pysqlcipher
 
 SQLAlchemy supports Python 2K and Python 3K in place though the above 
 dialect has probably not been tested on Py3K.
pysqlcipher does not support Py3K.
https://github.com/leapcode/pysqlcipher/issues/3
It's a known issue.

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


Re: [sqlalchemy] Support for pysqlcipher3

2015-05-31 Thread Mike Bayer



On 5/31/15 8:58 PM, Fayaz Yusuf Khan wrote:

On Sunday 31 May 2015 11:06:32 AM Mike Bayer wrote:

pysqlcipher is right here:

http://docs.sqlalchemy.org/en/rel_1_0/dialects/sqlite.html#module-sqlalchemy
.dialects.sqlite.pysqlcipher

SQLAlchemy supports Python 2K and Python 3K in place though the above
dialect has probably not been tested on Py3K.

pysqlcipher does not support Py3K.
https://github.com/leapcode/pysqlcipher/issues/3
It's a known issue.


you can send in pysqlcipher3 to create_engine() using the dbapi 
argument:


import pysqlcipher3
e = create_engine(sqlite+pysqlcipher:///file.db, dbapi=pysqlcipher3)

feel free to submit a PR that returns this DBAPI from the dbapi method 
under py3k:



https://bitbucket.org/zzzeek/sqlalchemy/src/0766c80b9c02fdbad3203835ab850ad690f4c03b/lib/sqlalchemy/dialects/sqlite/pysqlcipher.py?at=master#cl-82






--
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


[sqlalchemy] Support for pysqlcipher3

2015-05-31 Thread Fayaz Yusuf Khan
Hi,

pysqlcipher3 is a Python3 port for pysqlcipher (for SQLite). Does SQLA 
currently have support for this? (I wasn't able to get it running for my 
project.)
If not, any chances it will, in the future?

Thanks.

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


[sqlalchemy] Re: ...and MVC

2015-05-31 Thread Fayaz Yusuf Khan


On Tuesday, May 26, 2015 at 11:04:34 PM UTC+5:30, Jonathan Vanasco wrote:

 It is incredibly non-standard to have more than one transaction within a 
 given request.  It is also relatively non-standard to explicitly manage 
 transactions in the application code.

 I do both of those (the former in very few circumstances) but am in a tiny 
 minority of users.


I do the former in cases which involve very long transactions. (Batch 
uploads and processing. I'm counting batch and background tasks as part of 
the controller layer here.)


 If you decide to handle session state yourself, you will need to address 
 the intricacies of lazy-loading and collections.  If a collection/attribute 
 is not eager loaded, accessing it in a template will trigger a database 
 query. If you have already closed the connection or session, sqlalchemy 
 will reconnect and reload.


 I think they were talking about detaching objects from the session so that 
there's no way it'll reconnect with the database or make any further 
queries. I'm not saying I'd recommend it as it sounds... extreme. But what 
do I know?

I usually only keep `session.commit()` calls in the controllers. Every 
other database operation is buried in the models and helper functions.

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


Re: [sqlalchemy] Declarative: defining relationship and column in one line

2015-05-31 Thread Fayaz Yusuf Khan
Hi,

On Tuesday, May 19, 2015 at 7:41:45 PM UTC+5:30, Michael Bayer wrote:


 http://techspot.zzzeek.org/2011/05/17/magic-a-new-orm/

 I had tried this one before but it looked like those columns were never 
added to the underlying table.

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.