急!!用python连接数据库
我想用python连接到一个网上的数据库,但是我不知道怎么写那个code才能连接到那个数据库。我之前用过SAS,但是本人对SAS不太了解,所以不太懂怎么把存在remote...
我想用python连接到一个网上的数据库,但是我不知道怎么写那个code才能连接到那个数据库。我之前用过SAS,但是本人对SAS不太了解,所以不太懂怎么把存在remote server上的文件拷贝到local PC。 所以我想改用python去下载数据。
我之前SAS的code是这样的
%let wrds=wrds.wharton.upenn.edu 4016;
options comamid=TCP remote=WRDS;
signon username="XXX" password="XXX";
rsubmit;
libname SECa "/wrds/sec/archives";
options obs=1000;
/* WRDS SEC Analytics Suite: Example */
*libname sec_r '/wrds/sec/sasdata' server=wrds;
libname work_r (work) server=wrds;
libname sec '/wrds/sec/sasdata';
options sasautos=('/wrds/wrdsmacros/', SASAUTOS) MAUTOSOURCE;
data wrds_sec1;
set sec.wforms; format FNAME2 $100. ;
where form like '%10%K%' and CIK in ('0000078003') and fsize>0;
FNAME2 = cats("/wrds/sec/archives/",FNAME);
drop FINDEXDATE LINDEXDATE SOURCE FNAME ISIZE;
run;
希望有哪位大神可以帮助一下我 展开
我之前SAS的code是这样的
%let wrds=wrds.wharton.upenn.edu 4016;
options comamid=TCP remote=WRDS;
signon username="XXX" password="XXX";
rsubmit;
libname SECa "/wrds/sec/archives";
options obs=1000;
/* WRDS SEC Analytics Suite: Example */
*libname sec_r '/wrds/sec/sasdata' server=wrds;
libname work_r (work) server=wrds;
libname sec '/wrds/sec/sasdata';
options sasautos=('/wrds/wrdsmacros/', SASAUTOS) MAUTOSOURCE;
data wrds_sec1;
set sec.wforms; format FNAME2 $100. ;
where form like '%10%K%' and CIK in ('0000078003') and fsize>0;
FNAME2 = cats("/wrds/sec/archives/",FNAME);
drop FINDEXDATE LINDEXDATE SOURCE FNAME ISIZE;
run;
希望有哪位大神可以帮助一下我 展开
展开全部
settings.py
if DEBUG:
DATABASES = {
'default': {
'ENGINE': 'mysql', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
'NAME': '库名', # Or path to database file if using sqlite3.
'USER': 'root', # Not used with sqlite3.
'PASSWORD': '', # Not used with sqlite3.
'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '3306', # Set to empty string for default. Not used with sqlite3.
},
'库名': {
'ENGINE': 'mysql', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
'NAME': '库名', # Or path to database file if using sqlite3.
'USER': 'root', # Not used with sqlite3.
'PASSWORD': '', # Not used with sqlite3.
'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '3306', # Set to empty string for default. Not used with sqlite3.
}
}
if DEBUG:
DATABASES = {
'default': {
'ENGINE': 'mysql', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
'NAME': '库名', # Or path to database file if using sqlite3.
'USER': 'root', # Not used with sqlite3.
'PASSWORD': '', # Not used with sqlite3.
'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '3306', # Set to empty string for default. Not used with sqlite3.
},
'库名': {
'ENGINE': 'mysql', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
'NAME': '库名', # Or path to database file if using sqlite3.
'USER': 'root', # Not used with sqlite3.
'PASSWORD': '', # Not used with sqlite3.
'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '3306', # Set to empty string for default. Not used with sqlite3.
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询