Posting in english may be a better idea....j --rob Sent from my cell...excuse typos On Oct 28, 2013 10:35 AM, "Carlynhos77" <carlynho...@hotmail.com> wrote:
> ola, realmente esse trem nao vai... criei o arquivo db.py, joguei o codigo > nele, tirei as referencias do gluon, dai ja veio outros erros... > > vou rever os videos do curso q fiz com o bruno rocha, apesar o curso ser > voltado para o SQLLITE, em algum lugar ele fala das conexoes, vou ver se > ele diz algo sobre postgresql, esse projeto q to começando é baseado nas > explicacoes e ensinamentos q ele deu... acho q por isso ta dificil eu > alterar, pois foi feito e configurado pro sqllite... vou estudar mais, do > jeito q ta nao vai... > > agradeço imensamente sua ajuda OVIDIO, e desculpa por nao dá o retorno d > sucesso... > > > > Em segunda-feira, 28 de outubro de 2013 08h44min52s UTC-2, Ovidio Marinho > escreveu: >> >> Porque voce nao usa a ORM do web2py, e esta tentando criar o que existe >> em models, nao mexa na configuração do gluon >> >> no seu db.py use no local do sqlite: >> >> import psycopg2 >> >> db = DAL('postgres://usuario:senha@**localhost:5432/meubanco') >> >> OBS.: Usuario do Postgresql e senha do postgres. >> >> >> >> >> >> >> Ovidio Marinho Falcao Neto >> ITJP.NET.BR >> ovid...@gmail.com >> Brasil >> >> >> >> Em 27 de outubro de 2013 11:06, Jose Carlos Vicente Pereira < >> carly...@gmail.com> escreveu: >> >>> Ola, bom dia... estou tentando conectar meu banco postgresql ao meu >>> projeto, so q nao consigo.. veja meu codigo detalhado abaixo... >>> >>> ------------------------------**------------------------------** >>> ------------------------------**------------------------------** >>> -------------------- >>> *no MODELS - "appsettings.py" ta assim* >>> >>> from gluon.storage import Storage >>> config = Storage( >>> db=Storage(), >>> mail=Storage(), >>> auth=Storage() >>> ) >>> >>> import psycopg2 >>> #conn = psycopg2.connect(host='**localho**st', user='postgres', >>> password='123',dbname='saude') >>> conn = psycopg2.connect("dbname=saude user=postgres") >>> db = conn.cursor() >>> >>> config.mail.sender = "alu...@blouweb.com" >>> config.mail.server = "smtp.gmail.com:587" # "smtp.dddd:25" >>> config.mail.login = "alu...@blouweb.com:" >>> >>> response.title = "INFO-SAÚDE" >>> response.description = "SAÚDE" >>> >>> # glob >>> response.generic_patterns = ['*'] >>> >>> *no MODELS "database.py" tem isso, no sqllite isso era usado, acho >>> q pro postgresql nao sera usado* >>> >>> #coding: utf-8 >>> >>> # conectar ao banco de dados >>> # setar opcoes da DAL >>> >>> db = DAL(**config.db) >>> >>> >>> *no MODELS "datamodel_objects.py" isso foi usado para criar as >>> tabelas no sqllite, no postgresql ja criei as tabelas* >>> >>> db.define_table("cadcidade", >>> Field("nome", "text", length=128, notnull=True, unique=True), >>> Field("uf", "text", length=2, notnull=True), >>> Field("cep", "text", length=8, notnull=True), >>> Field("cod_ibge", "integer", length=7), >>> auth.signature, >>> format="%(nome)s" >>> ) >>> >>> >>> *no CONTROLLERS "bases.py" tem esse codigo pra gerar a grid* >>> * >>> * >>> def list_cidade(): >>> query = db.cadcidade.id > 0 >>> headers = {'cadcidade.nome': 'NOME', >>> 'cadcidade.uf': 'UF', >>> 'cadcidade.cep': 'CEP', >>> 'cadcidade.cod_ibge': 'IBGE' } >>> >>> grid = SQLFORM.grid(query=query, >>> user_signature=False, >>> paginate=20, >>> searchable=False, >>> csv=False, >>> fields=[db.cadcidade.nome, db.cadcidade.uf, db.cadcidade.cep, >>> db.cadcidade.cod_ibge], >>> orderby=db.cadcidade.nome, >>> headers=headers >>> ) >>> return dict(grid=grid) >>> >>> >>> dai esse *CONTROLLER* é exibido numa *VIEWS - BASES* - >>> "list_cidade.html" o codigo ta assim... >>> >>> {{extend 'layout.html'}} >>> >>> {{block main}} >>> >>> <H2 ALIGN=CENTER> >>> <FONT FACE="MS Mincho" COLOR="blue" SIZE="6"> CIDADES </font> >>> </H2> >>> >>> <div class="alert alert-info"> >>> {{=grid}} >>> </div> >>> >>> {{end}} >>> >>> >>> esse é o caminho q usei, a view ta sendo carregado sem erro, so q ta >>> ligada no banco DUMMY.DB, acho q se nao tem conexao d banco o aplicativo >>> gera esse banco automatico... >>> >>> o postgresql ta instalado correto, pois abro ele pelo PgAdmin e mexo nas >>> tabelas sem problemas >>> >>> lembrando q usando a conexao do sqllite o projeto funciona sem >>> problemas... >>> ------------------------------**------------------------------** >>> ------------------------------**------------------------------** >>> ------------------------------**--------------------- >>> >>> alguem pode me ajudar? >>> >>> >>> -- >>> Resources: >>> - http://web2py.com >>> - http://web2py.com/book (Documentation) >>> - http://github.com/web2py/**web2py >>> <http://github.com/web2py/web2py>(Source code) >>> - >>> https://code.google.com/p/**web2py/issues/list<https://code.google.com/p/web2py/issues/list>(Report >>> Issues) >>> --- >>> You received this message because you are subscribed to the Google >>> Groups "web2py-users" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to web2py+un...@**googlegroups.com. >>> For more options, visit >>> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out> >>> . >>> >> >> -- > Resources: > - http://web2py.com > - http://web2py.com/book (Documentation) > - http://github.com/web2py/web2py (Source code) > - https://code.google.com/p/web2py/issues/list (Report Issues) > --- > You received this message because you are subscribed to the Google Groups > "web2py-users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to web2py+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.