[sqlalchemy] SA connect to database remotely

2013-03-13 Thread junepeach
Hello All, Using sqlalchemy ORM, I have no problem to create a database in mysql locally. If I have mysql installed in a different machine (ip address: 10.7.0.127), and my tables defined in this machine (10.7.0.121). Now I want to create my database tables in mysql database of machine

Re: [sqlalchemy] SA connect to database remotely

2013-03-13 Thread junepeach
I changed the my.conf file and let the bind ip to 0.0.0.0. However when I tested again, same thing also happened by running your code: sqlalchemy.exc.OperationalError: (OperationalError) (1130, Host 'MYPC-8.local' is not allowed to connect to this MySQL server) None None What I need to change

Re: [sqlalchemy] SA connect to database remotely

2013-03-13 Thread junepeach
After googling, I found out below code to make it work: $ mysql -u root -p Enter password: mysql use mysql mysql GRANT ALL ON *.* to root@'192.168.1.4' IDENTIFIED BY 'your-root-password'; mysql FLUSH PRIVILEGES; Thanks a lot! LYH -- You received this message because you are subscribed to

Re: [sqlalchemy] SA connect to database remotely

2013-03-13 Thread junepeach
OOPs, my mistake. Simon, your command is running fine. But it still doesn't work in sqlalchemy ORM code: Traceback (most recent call last): File saintdb_data_model.py, line 55, in module execute = create_engine('mysql://root:mypwd@10.7.0.127:3306').connect().execute File

Re: [sqlalchemy] SA connect to database remotely

2013-03-13 Thread junepeach
Never mind, It was password typo problem. 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,

Re: [sqlalchemy] mysql_DEFAULT_CHARSET doesn't work with ForeignKeyConstraint func

2013-02-21 Thread junepeach
root@luck:/home/Documents# alembic upgrade head INFO [alembic.migration] Context impl MySQLImpl. INFO [alembic.migration] Will assume non-transactional DDL. INFO [alembic.migration] Running upgrade None - d28a086e79d Traceback (most recent call last): File /usr/local/bin/alembic, line 9, in

Re: [sqlalchemy] mysql_DEFAULT_CHARSET doesn't work with ForeignKeyConstraint func

2013-02-21 Thread junepeach
Thank you very much! It works now :) -- 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] How to migrate Json fromat data into mysql database?

2013-02-18 Thread junepeach
I don't know if I should post this question here, but I think it may relate to sqlalchemy. So sorry if it is not right place to post :) We may store our database data in a json format file, and then we need to migrate the data from json file into our mysql database (or other database we will

Re: [sqlalchemy] Re: How to create a temporary table in SA ORM

2013-02-11 Thread junepeach
Thanks Audrius. Do you have an example for how to select the data from multiple tables and insert into that temporary table? Best, LYH -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and stop receiving emails from

[sqlalchemy] Re: How to create a temporary table in SA ORM

2013-02-10 Thread junepeach
Thanks very much for the explanation about the difference between view and temporary table. But now, I am thinking about how to realize it in sqlalchemy and use it in as many databases as possible. Best wishes, LYH -- You received this message because you are subscribed to the Google Groups

[sqlalchemy] how to create mysql database in sqlalchemy?

2013-01-07 Thread junepeach
I ran below code as a root user: import sqlalchemy engine = sqlalchemy.create_engine('mysql://user:password@server') # connect to server engine.execute(CREATE DATABASE mydb) #create db engine.execute(USE mydb) # select new db However the database couldn't be created. The error I got is: File

Re: [sqlalchemy] Got a problem when sqlalchemy 0.8.0b1 works with alembic 0.3.6

2013-01-03 Thread junepeach
Thank you! I will try :) -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To view this discussion on the web visit https://groups.google.com/d/msg/sqlalchemy/-/DHXCcCqDu-MJ. To post to this group, send email to sqlalchemy@googlegroups.com. To

[sqlalchemy] Why I couldn't find my module (alembic autogenerate)?

2012-12-12 Thread junepeach
I installed alembic tool in 3 of my computers. 2 of them finally worked fine, but this one doesn't work with the same configuration. I tried both of below code in env.py: 1) import os, sys sys.path.append(os.getcwd()) from dbmodule import SAINT8 target_metadata = SAINT8.Base.metadata 2) I

Re: [sqlalchemy] Re: Is it possible for alembic or other migration tool to handle case sensitivity or insensitivity across database engines

2012-12-12 Thread junepeach
Sorry, I haven't touched that issue recently. Where I should turn on 'echo=true', in module or migration script? I saw 'create_engine' has this, but I didn't directly use 'create_engine'. SHOW CREATE TABLE gave something back to me: utf8_general_ci is default collation rule in charset utf8.

Re: [sqlalchemy] Re: Is it possible for alembic or other migration tool to handle case sensitivity or insensitivity across database engines

2012-12-12 Thread junepeach
Please ignore it, actually you are right, when I changed to collation 'utf8_unicode_ci', it works perfectly fine. Thanks a lot! -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To view this discussion on the web visit

[sqlalchemy] how to migrate database data from sqlite to mysql?

2012-12-08 Thread junepeach
I am looking for an efficient way to migrate all of the data in sqlite DB to mysql DB using sqlalchemy. Does anybody here know about it. I really appreciate if you can post your testing code in this forum. I searched online and found this link:

Re: [sqlalchemy] Re: Is it possible for alembic or other migration tool to handle case sensitivity or insensitivity across database engines

2012-12-07 Thread junepeach
UTC-5, Audrius Kažukauskas wrote: On Thu, 2012-12-06 at 17:43:45 -0800, junepeach wrote: How to upgrade to a newer sqlalchemy version? I can not find a related document. Should I just use pip to install the current one? Will both version conflict? The answer depends on how and where SA

Re: [sqlalchemy] Re: Is it possible for alembic or other migration tool to handle case sensitivity or insensitivity across database engines

2012-12-07 Thread junepeach
=InnoDB DEFAULT CHARSET=latin1; and created table in sqlite: CREATE TABLE atable ( name VARCHAR(200) COLLATE NOCASE ); Do I need to change something in the code? On Friday, December 7, 2012 4:15:18 PM UTC-5, Michael Bayer wrote: On Dec 7, 2012, at 4:01 PM, junepeach wrote: Thank you Mike

[sqlalchemy] Is it possible for alembic or other migration tool to handle case sensitivity or insensitivity across database engines

2012-12-06 Thread junepeach
For case insensitive columns: MySQL - use utf8_general_ci SQLite - use NOCASE collation Can migration tool handle that for most databases or it should be better done in application code? Thanks and best regards, -- You received this message because you are subscribed to the Google

[sqlalchemy] Re: Is it possible for alembic or other migration tool to handle case sensitivity or insensitivity across database engines

2012-12-06 Thread junepeach
Thanks, this is nice, I will use it in my code. On Thursday, December 6, 2012 3:17:25 PM UTC-5, junepeach wrote: For case insensitive columns: MySQL - use utf8_general_ci SQLite - use NOCASE collation Can migration tool handle that for most databases or it should be better done

[sqlalchemy] Re: Is it possible for alembic or other migration tool to handle case sensitivity or insensitivity across database engines

2012-12-06 Thread junepeach
it resolved, what is wrong? Thanks, jp On Thursday, December 6, 2012 4:10:01 PM UTC-5, junepeach wrote: Thanks, this is nice, I will use it in my code. On Thursday, December 6, 2012 3:17:25 PM UTC-5, junepeach wrote: For case insensitive columns: MySQL - use utf8_general_ci SQLite - use

Re: [sqlalchemy] Re: Is it possible for alembic or other migration tool to handle case sensitivity or insensitivity across database engines

2012-12-06 Thread junepeach
Oh, I see, mine is not sqlalchemy 0.8. Thanks. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To view this discussion on the web visit https://groups.google.com/d/msg/sqlalchemy/-/dvjzhmyWicoJ. To post to this group, send email to

Re: [sqlalchemy] Re: Is it possible for alembic or other migration tool to handle case sensitivity or insensitivity across database engines

2012-12-06 Thread junepeach
How to upgrade to a newer sqlalchemy version? I can not find a related document. Should I just use pip to install the current one? Will both version conflict? Thank you very much for your quick response and help! JP -- You received this message because you are subscribed to the Google Groups

Re: [sqlalchemy] Do we have a sqlalchemy code or migration script to enforce foreign key constraint for sqlite3?

2012-12-05 Thread junepeach
I am Python 2.7.3, and SQLite version 3.7.9. I added the code you guys mentioned above to the env.py script: from __future__ import with_statement from alembic import context from sqlalchemy import engine_from_config, pool from logging.config import fileConfig # this is the Alembic Config

Re: [sqlalchemy] Do we have a sqlalchemy code or migration script to enforce foreign key constraint for sqlite3?

2012-12-05 Thread junepeach
I think one of my problems is after defining: def set_sqlite_pragma(dbapi_connection, connection_record) in env.py, Where I should call it and what are the values of 2 arguments: dbapi_connection, connection_record? -- You received this message because you are subscribed to the Google

Re: [sqlalchemy] Do we have a sqlalchemy code or migration script to enforce foreign key constraint for sqlite3?

2012-12-05 Thread junepeach
Thank you Audrius.Maybe when I ran 'alembic upgrade head', 'PRAGMA foreign_keys' value of the current sqlite DB connection was already changed to 1 which I need to test in a python code. However when I manually logged in by typing 'sqlite3 mydb', this is another connection, so the 'PRAGMA

Re: [sqlalchemy] Do we have a sqlalchemy code or migration script to enforce foreign key constraint for sqlite3?

2012-12-05 Thread junepeach
I was wrong in above post. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To view this discussion on the web visit https://groups.google.com/d/msg/sqlalchemy/-/sgyxJHCVUm0J. To post to this group, send email to sqlalchemy@googlegroups.com. To

Re: [sqlalchemy] Do we have a sqlalchemy code or migration script to enforce foreign key constraint for sqlite3?

2012-12-05 Thread junepeach
, 2012 10:35:26 AM UTC-5, Audrius Kažukauskas wrote: On Wed, 2012-12-05 at 07:04:57 -0800, junepeach wrote: Thank you Audrius.Maybe when I ran 'alembic upgrade head', 'PRAGMA foreign_keys' value of the current sqlite DB connection was already changed to 1 which I need to test in a python

Re: [sqlalchemy] Do we have a sqlalchemy code or migration script to enforce foreign key constraint for sqlite3?

2012-12-05 Thread junepeach
Audrius Kažukauskas Hi Audrius, Your code works like a charm. Thank you so much for your help! I really appreciate! On Wednesday, December 5, 2012 12:53:25 PM UTC-5, Audrius Kažukauskas wrote: On Wed, 2012-12-05 at 09:07:20 -0800, junepeach wrote: I just did a testing, basically copied

[sqlalchemy] Why not seeing ondelete='xxx', and onupdate='xxx' in alembic migration script?

2012-12-05 Thread junepeach
I defined several tables in my module file: mymodule.py. For example I have table T1 and T2 defined: class T1(Base): __tablename__ = 't1' id = Column(Integer, primary_key = True) name = Column(String(15)) class T2(Base): __tablename__ = 't2' id = Column(Integer, primary_key =

[sqlalchemy] Do we have a sqlalchemy code or migration script to enforce foreign key constraint for sqlite3?

2012-12-04 Thread junepeach
We can turn on 'PRAGMA foreign_key = on' when running sqlite3 database system manually. However it is not a convenient way. So I wonder when I run the migration script using sqlalchemy and alembic tool, targeting sqlite3, is there a way to enforce the foreign key constraint in the migration

Re: [sqlalchemy] Do we have a sqlalchemy code or migration script to enforce foreign key constraint for sqlite3?

2012-12-04 Thread junepeach
Thanks Audrius. Do you have a simple working example in sqlalchemy? I am not familiar with sqlalchemy. My migration script will separate from other python development codes. So it is better to put 'PRAGMA foreign_keys=ON' in a configuration file. I am pretty new to all of those stuff. --

Re: [sqlalchemy] Do we have a sqlalchemy code or migration script to enforce foreign key constraint for sqlite3?

2012-12-04 Thread junepeach
I have tried this with no luck. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To view this discussion on the web visit https://groups.google.com/d/msg/sqlalchemy/-/WIhv75pJw3gJ. To post to this group, send email to sqlalchemy@googlegroups.com.

Re: [sqlalchemy] alembic handles no primary key table

2012-12-03 Thread junepeach
Thank you very much, Machiael. Yes, it helps a lot. So, to create migration script, when i should use ORM, and when I should use MetaData object? What is the difference? I have been confused about this two for long time. Please give more detail if you can :) Thanks again! -- You received this

Re: [sqlalchemy] alembic handles no primary key table

2012-12-02 Thread junepeach
THanks Werner and Michiael. Yeah ORM requires a primary key for every table. Michiael, I don't have a Metadata yet. I am creating a migration script to be shared among several databases. We will use this script to create tables schema in several databases. So, should we add a primary for this

Re: [sqlalchemy] alembic handles no primary key table

2012-12-01 Thread junepeach
I have 2 simple tables defined as below: class Test1(Base): __tablename__ = 'test1' id = Column(Integer, primary_key = True) name = Column(String(15)) class Test2(Base): __tablename__ = 'test2' fid = Column(Integer, ForeignKey('test1.id')) tname = Column(String(15)) You

[sqlalchemy] alembic handles no primary key table

2012-11-30 Thread junepeach
I know it is not good idea that there is no primary key in a table. But if some people just want to design a table like that, how can alembic tool handle that? It seems Alembic doesn't allow to create a non-primary key table. Thanks a lot and have a good weekend! -- You received this

[sqlalchemy] $PYTHONPATH setup for running Alembic?

2012-11-28 Thread junepeach
When using Alembic autogenerate command, we need to add a new module (mymodule) to $PYTHONPATH, and then configure env.py. $PYTHONPATH seems not stable. When I open an ubuntu terminal, and type: export PYTHONPATH=$PYTHONPATH:/home/mydir/mymodule, the new module is added into $PYTHONPATH

[sqlalchemy] $PYTHONPATH setup for running Alembic?

2012-11-28 Thread junepeach
at least I made a mistake for not creating a __init__ file under 'mymodule' dir. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To view this discussion on the web visit https://groups.google.com/d/msg/sqlalchemy/-/gJ-J3MAW-igJ. To post to this

[sqlalchemy] How to use collate/charset key words in sqlalchemy?

2012-11-19 Thread junepeach
If I should have a table 'mytable' defined like below in mysql database: CREATE TABLE mytable ( id int(11) NOT NULL AUTO_INCREMENT, fullname varchar(50)collate utf8_unicode_ci ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; How can I add the 'collate' clause and CHARSET

Re: [sqlalchemy] Failed to drop view when working with Postgresql in alembic migration script

2012-11-01 Thread junepeach
Thanks for the suggestion.I solved the problem by putting the dependents' drop command first in function def downgrade(): For example, if A refers to/uses B, I need to drop B first, then drop A. I don't know other better way. Will Alembic support 'cascade' in future version? -- You received

Re: [sqlalchemy] Failed to drop view when working with Postgresql in alembic migration script

2012-11-01 Thread junepeach
Thank you, I will test your above idea. By the way, I am new to both Alembic and Sqlalchemy. Right now our database has around 90 tables, and 12 views (could be more), and we would like to support as many databases as we can. Postgresql works fine with both 'alembic revision --autogenerate'

Re: [sqlalchemy] Failed to drop view when working with Postgresql in alembic migration script

2012-11-01 Thread junepeach
Yes, it is true for the view, but I also got below error when a view references tables: qlalchemy.exc.InternalError: (InternalError) cannot drop table tbl_1 because other objects depend on it DETAIL: view view_1 depends on table tbl_1 HINT: Use DROP ... CASCADE to drop the dependent objects

Re: [sqlalchemy] How to use BLOB datatype in alembic tool to support Postgresql?

2012-10-31 Thread junepeach
Thanks. Yes it works fine now. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To view this discussion on the web visit https://groups.google.com/d/msg/sqlalchemy/-/-Cx--STwfO4J. To post to this group, send email to sqlalchemy@googlegroups.com. To

[sqlalchemy] Failed to drop view when working with Postgresql in alembic migration script

2012-10-31 Thread junepeach
Hi Michael, I have several views defined in alembic migration script, and so I defined op.execute('drop view xxx') to drop all of my view sql files. When I ran script 'alembic downgrade -1' to drop all of the tables, views, indexes, MySQL, SQLITE3 worked fine. When working with Postgresql, I

[sqlalchemy] How to use BLOB datatype in alembic tool to support Postgresql?

2012-10-30 Thread junepeach
We want to support as many databases as we can. Right now we have BLOB data type defined in our database schemas, both sqlite3 and mysql work fine with Alembic migration tool on that data type, however it failed on Postgresql. How should we handle that if we really want to use BLOB datatype?

Re: [sqlalchemy] Re: Alembic 0.4.0 Released

2012-10-24 Thread junepeach
: op.execute(ALTER TABLE tbl AUTO_INCREMENT = 100) On Oct 23, 2012, at 5:18 PM, junepeach wrote: Alembic is cool :) How does AUTO_INCREMENT work for the below situation in MySQL: auto_increment = 10, or any integer which is not 1 (default value)? Thanks, Junepeach On Monday, October 1

[sqlalchemy] Re: Alembic 0.4.0 Released

2012-10-23 Thread junepeach
Alembic is cool :) How does AUTO_INCREMENT work for the below situation in MySQL: auto_increment = 10, or any integer which is not 1 (default value)? Thanks, Junepeach On Monday, October 1, 2012 8:27:54 PM UTC-4, Michael Bayer wrote: Alembic 0.4.0 is now available. Alembic