Re: [web2py] creating DAL from SQL file

2015-04-27 Thread Richard Vézina
You know what... You may consider using an older web2py version... If possible the version which saw this contrib be added, that way you should raise your chance to make it works properly... This guy : https://groups.google.com/d/msg/web2py/5GNG-g1M8T8/fq8UN1fqumMJ Report it was working, back to

Re: [web2py] creating DAL from SQL file

2015-04-25 Thread Ron Chatterjee
I got the code to run half way. I am saying, if we can bypass subprocess.Popen by: cat_str = 'SELECT *From' + " " + table_name[0] get_table = cursor.execute(cat_str) sql_create_stmnt = cursor.fetchall() I may not need to have mysqldump or anything. I just don't know what subprocess.Popen doe

Re: [web2py] creating DAL from SQL file

2015-04-25 Thread Richard Vézina
I never try it... I may try it for you, but not now, I am working late tonight to push a new app version in production :( >From the script doc : This plugin needs:mysqlmysqldumpinstalled and globally available.Under Windows you will probably need to add the mysql executable directory to the PATH

Re: [web2py] creating DAL from SQL file

2015-04-25 Thread Ron Chatterjee
I very simple question. Have you tried? Does the script works for you? Because it didn't work for me. Idk what you don't understand that I am doing. Its all the same code. someone can just step through it and figure out that its failing on subprocess.Popen. Idk why its so hard to understand. Sp

Re: [web2py] creating DAL from SQL file

2015-04-25 Thread Richard Vézina
I don't know what you are doing... As far as I can see the only thing you have to do is to is that you call the script with as argument a valid web2py db connection string... a database dump is what is say you dump your db into a file... But I don't think this script work like that, I thought it c

Re: [web2py] creating DAL from SQL file

2015-04-24 Thread Ron Chatterjee
Thanks for all the help Richard. I tried to work around the code extract_mysql_models.py (attached is the code). Basically, I installed XAMP/WAMP and in the phpmyadmin I have the sql database. I am running this code but it fails in line #74: p = subprocess.Popen(['mysqldump','--user=%s' % user

Re: [web2py] creating DAL from SQL file

2015-04-22 Thread Richard Vézina
The version in the thread seems not have been included in web2py... Try the one in gluon/scripts/ Richard On Wed, Apr 22, 2015 at 3:41 PM, Richard Vézina wrote: > This regex : regex = re.compile('(.*?):(.*?)@(.*)') > > Seems to parse the below command line call!! > > Richard > > On Wed, Apr 22

Re: [web2py] creating DAL from SQL file

2015-04-22 Thread Richard Vézina
This regex : regex = re.compile('(.*?):(.*?)@(.*)') Seems to parse the below command line call!! Richard On Wed, Apr 22, 2015 at 3:39 PM, Richard Vézina wrote: > > https://github.com/web2py/web2py/blob/master/scripts/extract_mysql_models.py > > Ok, it is not working exactly how I thought it wa

Re: [web2py] creating DAL from SQL file

2015-04-22 Thread Richard Vézina
https://github.com/web2py/web2py/blob/master/scripts/extract_mysql_models.py Ok, it is not working exactly how I thought it was... Do you have myslqldump install? Do you use Linux or Windows... what if you do python extract_mysql_models.py username:password@data_basename On Wed, Apr 22, 2015 a

Re: [web2py] creating DAL from SQL file

2015-04-22 Thread Ron Chatterjee
I used this version (the first one) and change to MySQLdb. https://groups.google.com/forum/#!searchin/web2py/extract_mysql_models.py/web2py/XPoTlzPG7lQ/ngSsMbd6zHAJ It gives me an error: Basically, This worked db = MySQLdb.connect(host = 'localhost',user ='root',passwd = '',db = 'name_of_my_d

Re: [web2py] creating DAL from SQL file

2015-04-22 Thread Richard Vézina
What do you exactly get out of extract_mysql_models.py applied over an SQL dump of the schema (only no data inserts)? Richard On Wed, Apr 22, 2015 at 2:29 PM, Ron Chatterjee wrote: > Sorry, wasn't clear. Basically want to create a DAL (db.py) file from an > existing site that I locally hosted (

Re: [web2py] creating DAL from SQL file

2015-04-22 Thread Ron Chatterjee
Sorry, wasn't clear. Basically want to create a DAL (db.py) file from an existing site that I locally hosted (wAMP) which is php front end mysql backend. I exported out of my WAMP (phpmysqladmin) the tables and fields in SQL language. Then I tried to make DAL out of it. As you explained, thats

Re: [web2py] creating DAL from SQL file

2015-04-22 Thread Richard Vézina
Hello Ron, The more this thread goes the less I understand what you are trying to acheive... Do you want to translate a SQLite DB into a web2py model? or MySQL DB? If you do have a MySQL server instance your connection string seems correct... But then you have to define the table you want to acces

Re: [web2py] creating DAL from SQL file

2015-04-22 Thread Ron Chatterjee
This is what I was looking for. https://groups.google.com/forum/#!searchin/web2py/extract_mysql_models.py/web2py/XPoTlzPG7lQ/ngSsMbd6zHAJ But homehow the code didn't work for me even when I followed the example like it says. So, I am creating a stand alone version that works with MySQLdb.

Re: [web2py] creating DAL from SQL file

2015-04-21 Thread Ron Chatterjee
I have sqlite browser. I am guessing its the same like SQlite Manager where someone can import, export csv or sql file. I don't have password in that database and work externally to the python *I guess one possibility will be:* import MySQLdb import sys try: db = MySQLdb.connect(host = 'loc

Re: [web2py] creating DAL from SQL file

2015-04-21 Thread Richard Vézina
And what would be the utility since you already have INSERT INTO TABLE... Someone can just use something like SQLite Manager ( https://addons.mozilla.org/en-us/firefox/addon/sqlite-manager/) to import it... Once in SQLite DB (which anyway it should) he can use web2py csv export import if he want to

Re: [web2py] creating DAL from SQL file

2015-04-21 Thread Niphlod
On Tuesday, April 21, 2015 at 9:39:14 PM UTC+2, Ron Chatterjee wrote: > > I tried this: > > db = > DAL('mysql://root@127.0.0.1:8000/my_database_name',migrate_enabled=False, > pool_size=20) > > It didn't work either. I guess someone needs to look at how to connect to > legacy database. > > whe

Re: [web2py] creating DAL from SQL file

2015-04-21 Thread Ron Chatterjee
I tried this: db = DAL('mysql://root@127.0.0.1:8000/my_database_name',migrate_enabled=False, pool_size=20) It didn't work either. I guess someone needs to look at how to connect to legacy database. On Tuesday, April 21, 2015 at 2:49:33 PM UTC-4, Ron Chatterjee wrote: > > I can write it. Bu

Re: [web2py] creating DAL from SQL file

2015-04-21 Thread Ron Chatterjee
I can write it. But it will take some time to go through the syntax. I will let you know. On Tuesday, April 21, 2015 at 2:35:29 PM UTC-4, Richard wrote: > > I can't I remember having read that mysql script worked or have been > used... You may consider write a dummy web2py model generate the D

Re: [web2py] creating DAL from SQL file

2015-04-21 Thread Richard Vézina
I can't I remember having read that mysql script worked or have been used... You may consider write a dummy web2py model generate the DB (SQLite) export the SQLite Schema and attach here or to a ticket you open on github it will help to troobleshoot and fix it... Richard On Tue, Apr 21, 2015 at 2

Re: [web2py] creating DAL from SQL file

2015-04-21 Thread Ron Chatterjee
Can you confirm if it was working before? I just don't know if it was. On Tuesday, April 21, 2015 at 11:56:27 AM UTC-4, Richard wrote: > > :) > > You may also consider fixing the scripts which may just need a little > tweak if it where working before... > > Richard > > On Tue, Apr 21, 2015 at 11:

Re: [web2py] creating DAL from SQL file

2015-04-21 Thread Richard Vézina
:) You may also consider fixing the scripts which may just need a little tweak if it where working before... Richard On Tue, Apr 21, 2015 at 11:12 AM, Ron Chatterjee wrote: > I need to stop being lazy I guess. lol. Thanks Richard. Will do. > > On Tuesday, April 21, 2015 at 12:52:31 AM UTC-4, R

Re: [web2py] creating DAL from SQL file

2015-04-21 Thread Ron Chatterjee
I need to stop being lazy I guess. lol. Thanks Richard. Will do. On Tuesday, April 21, 2015 at 12:52:31 AM UTC-4, Richard wrote: > > Does the script complete correctly... These scripts are old, and I don't > know many person who have use them... Anyway, 20 tables 50 tables is not > much... > > Y

Re: [web2py] creating DAL from SQL file

2015-04-20 Thread Richard Vézina
Does the script complete correctly... These scripts are old, and I don't know many person who have use them... Anyway, 20 tables 50 tables is not much... You can write your own which can be basic parser that convert table and field only and you have to set constrains yourself... Richard On Mon,

Re: [web2py] creating DAL from SQL file

2015-04-20 Thread Ron Chatterjee
Yes I did. I forgot to add. The extract_sqlite_models.py didn't work as expect. And that may be because I am not doing it right. Thats why I didn't mention. >>>python extract_sqlite_models.py C:\Users\...\applications\my_application_name\databases\storage.sqlite Which generates the following

Re: [web2py] creating DAL from SQL file

2015-04-20 Thread Richard Vézina
https://github.com/web2py/web2py/blob/master/scripts/extract_sqlite_models.py Have you check gluon/scripts/ before ask? Richard On Sun, Apr 19, 2015 at 5:07 PM, Ron Chatterjee wrote: > I have the following SQL file: > > BEGIN TRANSACTION; > CREATE TABLE topic( > id INTEGER PRIMARY KEY AUTO

[web2py] creating DAL from SQL file

2015-04-19 Thread Ron Chatterjee
I have the following SQL file: BEGIN TRANSACTION; CREATE TABLE topic( id INTEGER PRIMARY KEY AUTOINCREMENT, title CHAR(512) NOT NULL, is_active CHAR(1), created_on TIMESTAMP, created_by INTEGER REFERENCES auth_user (id) ON DELETE CASCADE, modified_on TIMESTAMP, modified