[sqlalchemy] Redefine class on runtime

2019-03-03 Thread Tolstov Sergey
Hi, for unit tests i need to create class with *Base.metadata.create_all*, 
and delete table defintion (for tests)

On second definition i have a error (already defined)

With use *Base.metadata.clear *i get *warning*

SAWarning: Reassigning polymorphic association for identity 
'testparentclass' from  to 
: Check for duplicate use of 
'testparentclass' as value for polymorphic_identity.

Can i clear cached inherit?

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
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 https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


[sqlalchemy] MySQL Connector

2019-03-03 Thread Warwick Prince
Hi Community

We’ve been using sqlalchemy with great success for many years.  We’ve been 
using the mysqlconnector to connect to my MySQL databases with no issues to 
speak of.

My issue is that I recently upgraded to the latest version of the connector 
from Oracle which has changed from Python to C.  I’m now regularly receiving 
the following error where this has never happened in the past;   MySQL 5.6 BTW.

DatabaseError: (mysql.connector.errors.HashError) Hashed authentication data is 
invalid

Obviously, I would assume that this is not a sqlalchemy issue, however there’s 
nothing really being spoken about this anywhere else and I wondered if anyone 
had had the problem and fixed it - or eventually rolled back to the very old 
version of mysqlconnector?

Alternatively, @Mike - could you recommend in your opinion the ‘best’ connector 
to use for MySQL based on reliability and performance.

Cheers
Warwick

Warwick Prince 
Managing Director 
mobile: +61 411 026 992
skype: warwickprince   
phone: +61 7 3102 3730 
fax:  +61 7 3319 6734 
web: www.mushroomsys.com 

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
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 https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


[sqlalchemy] Re: Organizing a project

2019-03-03 Thread Jonathan Vanasco
I generally write the SqlAlchemy models as a separate package, then import 
that into my MVC/etc patterned app.

In terms of the SqlAlchemy logic, some of that I keep in the models 
package, others are in the core app.

This allows other apps and utilities to be built off the SqlAlchemy models 
and be imported cleanly.  This way cron jobs, migrations, admin tools, etc 
etc can just leverage a shared central model, which is fairly lean.  So my 
general advice is to approach things with two packages, one for [M] and the 
other for [VC]



On Sunday, March 3, 2019 at 6:19:29 PM UTC-5, Rich wrote:
>
> Starting my first SA project (have one more planned after this one's 
> working) and appreciate advice on organizing project files. I understand 
> the 
> MVC pattern and am trying to apply it with subdirectories of model/, 
> view/, 
> and controller/ yet I'm unsure where to place SQLAlchemy. 
>
> This is the overall structure: the backend is a postgresql database, SA 
> will 
> access it via psycopg2 (the engine should be properly configured for 
> this), 
> and the GUI is being written using tkinter. 
>
> Now, ../model/model.py has the classes that represent the postgres table; 
> ../views/ contains four files: data_entry_dialogs.py, ttkcalendar.py, 
> commonDlgs.py, and data_entry_validators.py; and ../controller/ is empty. 
>
> One of the classes in data_entry_dialogs.py has two ttk.Combobox widgets 
> whose values are in two classes in models.py. I assume that a properly 
> structured SA statement (not yet written or tested) can select the rows 
> from 
> the two tables, store them in a list, and that list passed to the 
> ttk.Comboboxes for their input_arg values. I'll work on an appropriate 
> statement RSN, but now want to learn whether to put all SA code in 
> models.py, in the model/ directory, or the controller/ directory. 
>
> If this is in the ORM tutorial I've missed seeing it so pointers to docs 
> that address these two issues are very welcome. 
>
> TIA, 
>
> Rich 
>
>

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
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 https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


[sqlalchemy] Organizing a project

2019-03-03 Thread Rich Shepard

Starting my first SA project (have one more planned after this one's
working) and appreciate advice on organizing project files. I understand the
MVC pattern and am trying to apply it with subdirectories of model/, view/,
and controller/ yet I'm unsure where to place SQLAlchemy.

This is the overall structure: the backend is a postgresql database, SA will
access it via psycopg2 (the engine should be properly configured for this),
and the GUI is being written using tkinter.

Now, ../model/model.py has the classes that represent the postgres table;
../views/ contains four files: data_entry_dialogs.py, ttkcalendar.py, 
commonDlgs.py, and data_entry_validators.py; and ../controller/ is empty.


One of the classes in data_entry_dialogs.py has two ttk.Combobox widgets
whose values are in two classes in models.py. I assume that a properly
structured SA statement (not yet written or tested) can select the rows from
the two tables, store them in a list, and that list passed to the
ttk.Comboboxes for their input_arg values. I'll work on an appropriate
statement RSN, but now want to learn whether to put all SA code in
models.py, in the model/ directory, or the controller/ directory.

If this is in the ORM tutorial I've missed seeing it so pointers to docs
that address these two issues are very welcome.

TIA,

Rich

--
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper


http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
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 https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.